From aaaa57f32a605e4ebd2e4230fe036afc009ae0a0 Mon Sep 17 00:00:00 2001
From: Donald Douwsma <ddouwsma@redhat.com>
Date: Fri, 14 Oct 2022 18:58:47 +1100
Subject: [PATCH 6/7] xfsrestore: untangle inventory unpacking logic
stobj_unpack_sessinfo returns bool_t, fix logic in pi_addfile so errors
can be properly reported.
Signed-off-by: Donald Douwsma <ddouwsma@redhat.com>
Reviewed-by: Darrick J. Wong <djwong@kernel.org>
Signed-off-by: Carlos Maiolino <cem@kernel.org>
---
diff --git a/restore/content.c b/restore/content.c
index b19bb90..8bb5fa4 100644
--- a/restore/content.c
+++ b/restore/content.c
@@ -5461,17 +5461,14 @@ pi_addfile( Media_t *Mediap,
* desc.
*/
sessp = 0;
- if ( ! buflen ) {
- ok = BOOL_FALSE;
- } else {
- /* extract the session information from the buffer */
- if ( stobj_unpack_sessinfo( bufp, buflen, &sessinfo )<0 ) {
- ok = BOOL_FALSE;
- } else {
+ ok = BOOL_FALSE;
+ /* extract the session information from the buffer */
+ if (buflen &&
+ stobj_unpack_sessinfo(bufp, buflen, &sessinfo)) {
stobj_convert_sessinfo(&sessp, &sessinfo);
ok = BOOL_TRUE;
- }
}
+
if ( ! ok || ! sessp ) {
mlog( MLOG_DEBUG | MLOG_WARNING | MLOG_MEDIA, _(
"on-media session "