[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[dm-devel] [PATCH] libdevmapper: (2/6) Fix trailing separator



Hi,

This patch fixes dm_report_output() so that it can correctly check
the end of the row.

It uses list_end() but trailing fields may have HIDDEN flag and
not be printed.

For example,
# dmsetup info -c -o name -O minor VG0-lv0
Name
VG0-lv0
# dmsetup info -c -o name -O minor --noheadings VG0-lv0
VG0-lv0:
# dmsetup info -c -o name --noheadings VG0-lv0
VG0-lv0

The patch fixes it by inserting hidden fields at the head of the list.

Thanks,
-- 
Jun'ichi Nomura, NEC Corporation of America
Later, dm_report_output() loops through rh->field_props list
and checks the end of the list by list_end() whether to display the
separator or not.
The check doesn't work if hidden field is on the tail.

For example, try 'dmsetup info -c -o name -O minor' and
compare the results with and without '--noheadings'.

---
 lib/libdm-report.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: device-mapper.work/lib/libdm-report.c
===================================================================
--- device-mapper.work.orig/lib/libdm-report.c
+++ device-mapper.work/lib/libdm-report.c
@@ -315,7 +315,12 @@ static struct field_properties * _add_fi
 	/* Add additional flags */
 	fp->flags |= flags;
 
-	list_add(&rh->field_props, &fp->list);
+	/* Hidden field must come first, otherwise list_end() doesn't work
+	   as expected */
+	if (fp->flags & FLD_HIDDEN)
+		list_add_h(&rh->field_props, &fp->list);
+	else
+		list_add(&rh->field_props, &fp->list);
 	return fp;
 }
 

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]