All of lore.kernel.org
 help / color / mirror / Atom feed
* device-mapper ./WHATS_NEW lib/libdm-report.c
@ 2007-01-18 22:15 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-01-18 22:15 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-01-18 22:15:04

Modified files:
	.              : WHATS_NEW 
	lib            : libdm-report.c 

Log message:
	Suppress 'Unrecognised field' error if report field is 'help'.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.152&r2=1.153
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.4&r2=1.5

--- device-mapper/WHATS_NEW	2007/01/18 17:47:56	1.152
+++ device-mapper/WHATS_NEW	2007/01/18 22:15:04	1.153
@@ -1,5 +1,6 @@
 Version 1.02.16 -
 ===================================
+  Suppress 'Unrecognised field' error if report field is 'help'.
   Add --separator and --sort to dmsetup (unused).
   Make alignment flag optional when specifying report fields.
 
--- device-mapper/lib/libdm-report.c	2007/01/18 21:59:02	1.4
+++ device-mapper/lib/libdm-report.c	2007/01/18 22:15:04	1.5
@@ -416,8 +416,9 @@
 		if (!_field_match(rh, ws, (size_t) (we - ws))) {
 			_display_fields(rh);
 			log_print(" ");
-			log_error("dm_report: Unrecognised field: %.*s",
-				  (int) (we - ws), ws);
+			if (strcasecmp(ws, "help") && strcmp(ws, "?"))
+				log_error("Unrecognised field: %.*s",
+					  (int) (we - ws), ws);
 			return 0;
 		}
 	}

^ permalink raw reply	[flat|nested] 5+ messages in thread

* device-mapper ./WHATS_NEW lib/libdm-report.c
@ 2007-04-19 20:24 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-04-19 20:24 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-04-19 21:24:00

Modified files:
	.              : WHATS_NEW 
	lib            : libdm-report.c 

Log message:
	Introduce _add_field() and _is_same_field() to libdm-report.c.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.174&r2=1.175
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.12&r2=1.13

--- device-mapper/WHATS_NEW	2007/04/19 19:10:19	1.174
+++ device-mapper/WHATS_NEW	2007/04/19 20:24:00	1.175
@@ -1,6 +1,7 @@
 Version 1.02.19 -
 ====================================
-  Fix libdevmapper-event memory leaks
+  Introduce _add_field() and _is_same_field() to libdm-report.c.
+  Fix some libdevmapper-event memory leaks.
   Remove unnecessary memset() return value checks.
   Fix a few leaks in reporting error paths. [1.02.15+]
 
--- device-mapper/lib/libdm-report.c	2007/02/14 15:12:16	1.12
+++ device-mapper/lib/libdm-report.c	2007/04/19 20:24:00	1.13
@@ -296,36 +296,67 @@
 	return 1;
 }
 
-static int _field_match(struct dm_report *rh, const char *field, size_t flen)
+static struct field_properties * _add_field(struct dm_report *rh,
+					    uint32_t field_num, uint32_t flags)
 {
-	uint32_t f, l;
 	struct field_properties *fp;
 
-	if (!flen)
-		return 0;
+	rh->report_types |= rh->fields[field_num].type;
 
-	for (f = 0; rh->fields[f].report_fn; f++) {
-		if ((!strncasecmp(rh->fields[f].id, field, flen) &&
-		     strlen(rh->fields[f].id) == flen) ||
-		    (l = strlen(rh->field_prefix),
-		     !strncasecmp(rh->field_prefix, rh->fields[f].id, l) &&
-		     !strncasecmp(rh->fields[f].id + l, field, flen) &&
-		     strlen(rh->fields[f].id) == l + flen)) {
-			rh->report_types |= rh->fields[f].type;
-			if (!(fp = dm_pool_zalloc(rh->mem, sizeof(*fp)))) {
-				log_error("dm_report: "
-					  "struct field_properties allocation "
-					  "failed");
-				return 0;
-			}
-			if (!_copy_field(rh, fp, f))
-				return 0;
+	if (!(fp = dm_pool_zalloc(rh->mem, sizeof(struct field_properties)))) {
+		log_error("dm_report: struct field_properties allocation "
+			  "failed");
+		return NULL;
+	}
 
-			list_add(&rh->field_props, &fp->list);
-			return 1;
-		}
+	if (!_copy_field(rh, fp, field_num)) {
+		stack;
+		dm_pool_free(rh->mem, fp);
+		return NULL;
 	}
 
+	fp->flags |= flags;
+	list_add(&rh->field_props, &fp->list);
+
+	return fp;
+}
+
+/*
+ * Compare name1 against name2 or prefix plus name2
+ * name2 is not necessarily null-terminated.
+ * len2 is the length of name2.
+ */
+static int _is_same_field(const char *name1, const char *name2,
+			  size_t len2, const char *prefix)
+{
+	size_t prefix_len;
+
+	/* Exact match? */
+	if (!strncasecmp(name1, name2, len2) && strlen(name1) == len2)
+		return 1;
+
+	/* Match including prefix? */
+	prefix_len = strlen(prefix);
+	if (!strncasecmp(prefix, name1, prefix_len) &&
+	    !strncasecmp(name1 + prefix_len, name2, len2) &&
+	    strlen(name1) == prefix_len + len2)
+		return 1;
+
+	return 0;
+}
+
+static int _field_match(struct dm_report *rh, const char *field, size_t flen)
+{
+	uint32_t f;
+
+	if (!flen)
+		return 0;
+
+	for (f = 0; rh->fields[f].report_fn; f++)
+		if (_is_same_field(rh->fields[f].id, field, flen,
+				   rh->field_prefix))
+			return _add_field(rh, f, 0) ? 1 : 0;
+
 	return 0;
 }
 
@@ -341,21 +372,8 @@
 		}
 	}
 
-	if (!found) {
-		rh->report_types |= rh->fields[field_num].type;
-		if (!(found = dm_pool_zalloc(rh->mem, sizeof(*found)))) {
-			log_error("dm_report: "
-				  "struct field_properties allocation failed");
-			return 0;
-		}
-		if (!_copy_field(rh, found, field_num))
-			return 0;
-
-		/* Add as a non-display field */
-		found->flags |= FLD_HIDDEN;
-
-		list_add(&rh->field_props, &found->list);
-	}
+	if (!found && !(found = _add_field(rh, field_num, FLD_HIDDEN)))
+		return_0;
 
 	if (found->flags & FLD_SORT_KEY) {
 		log_error("dm_report: Ignoring duplicate sort field: %s",
@@ -372,7 +390,7 @@
 
 static int _key_match(struct dm_report *rh, const char *key, size_t len)
 {
-	uint32_t f, l;
+	uint32_t f;
 	uint32_t flags;
 
 	if (!len)
@@ -394,16 +412,10 @@
 		return 0;
 	}
 
-	for (f = 0; rh->fields[f].report_fn; f++) {
-		if ((!strncasecmp(rh->fields[f].id, key, len) &&
-		     strlen(rh->fields[f].id) == len) ||
-		    (l = strlen(rh->field_prefix),
-		     !strncasecmp(rh->field_prefix, rh->fields[f].id, l) &&
-		     !strncasecmp(rh->fields[f].id + l, key, len) &&
-		     strlen(rh->fields[f].id) == l + len)) {
+	for (f = 0; rh->fields[f].report_fn; f++)
+		if (_is_same_field(rh->fields[f].id, key, len,
+				   rh->field_prefix))
 			return _add_sort_key(rh, f, flags);
-		}
-	}
 
 	return 0;
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* device-mapper ./WHATS_NEW lib/libdm-report.c
@ 2007-04-27 15:22 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2007-04-27 15:22 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2007-04-27 16:22:27

Modified files:
	.              : WHATS_NEW 
	lib            : libdm-report.c 

Log message:
	Avoid trailing separator in reports when there are hidden sort fields.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.178&r2=1.179
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.13&r2=1.14

--- device-mapper/WHATS_NEW	2007/04/27 15:12:26	1.178
+++ device-mapper/WHATS_NEW	2007/04/27 15:22:27	1.179
@@ -1,5 +1,6 @@
 Version 1.02.19 -
 ====================================
+  Avoid trailing separator in reports when there are hidden sort fields.
   Fix segfault in 'dmsetup status' without --showkeys against crypt target.
   Deal with some more compiler warnings.
   Introduce _add_field() and _is_same_field() to libdm-report.c.
--- device-mapper/lib/libdm-report.c	2007/04/19 20:24:00	1.13
+++ device-mapper/lib/libdm-report.c	2007/04/27 15:22:27	1.14
@@ -316,7 +316,15 @@
 	}
 
 	fp->flags |= flags;
-	list_add(&rh->field_props, &fp->list);
+
+	/*
+	 * Place hidden fields at the front so list_end() will
+	 * tell us when we've reached the last visible field.
+	 */
+	if (fp->flags & FLD_HIDDEN)
+		list_add_h(&rh->field_props, &fp->list);
+	else
+		list_add(&rh->field_props, &fp->list);
 
 	return fp;
 }

^ permalink raw reply	[flat|nested] 5+ messages in thread

* device-mapper ./WHATS_NEW lib/libdm-report.c
@ 2008-01-20  1:14 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2008-01-20  1:14 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2008-01-20 01:14:38

Modified files:
	.              : WHATS_NEW 
	lib            : libdm-report.c 

Log message:
	Use log_warn for reporting field help text instead of log_print.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.223&r2=1.224
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.15&r2=1.16

--- device-mapper/WHATS_NEW	2008/01/15 22:48:11	1.223
+++ device-mapper/WHATS_NEW	2008/01/20 01:14:38	1.224
@@ -1,5 +1,6 @@
 Version 1.02.25 - 
 ====================================
+  Use log_warn for reporting field help text instead of log_print.
   Change cluster mirror log type name (s/clustered_/clustered-/)
 
 Version 1.02.24 - 20th December 2007
--- device-mapper/lib/libdm-report.c	2007/08/21 16:26:06	1.15
+++ device-mapper/lib/libdm-report.c	2008/01/20 01:14:38	1.16
@@ -260,16 +260,16 @@
 			desc = " ";
 		if (desc != last_desc) {
 			if (*last_desc)
-				log_print(" ");
-			log_print("%s Fields", desc);
-			log_print("%*.*s", (int) strlen(desc) + 7,
-				  (int) strlen(desc) + 7,
-				  "------------------------------------------");
+				log_warn(" ");
+			log_warn("%s Fields", desc);
+			log_warn("%*.*s", (int) strlen(desc) + 7,
+				 (int) strlen(desc) + 7,
+				 "------------------------------------------");
 				  
 		}
 
 		/* FIXME Add line-wrapping at terminal width (or 80 cols) */
-		log_print("  %-*s - %s", (int) id_len, rh->fields[f].id, rh->fields[f].desc);
+		log_warn("  %-*s - %s", (int) id_len, rh->fields[f].id, rh->fields[f].desc);
 		last_desc = desc;
 	}
 }
@@ -444,7 +444,7 @@
 
 		if (!_field_match(rh, ws, (size_t) (we - ws))) {
 			_display_fields(rh);
-			log_print(" ");
+			log_warn(" ");
 			if (strcasecmp(ws, "help") && strcmp(ws, "?"))
 				log_error("Unrecognised field: %.*s",
 					  (int) (we - ws), ws);

^ permalink raw reply	[flat|nested] 5+ messages in thread

* device-mapper ./WHATS_NEW lib/libdm-report.c
@ 2008-06-25 19:52 agk
  0 siblings, 0 replies; 5+ messages in thread
From: agk @ 2008-06-25 19:52 UTC (permalink / raw)
  To: dm-cvs, dm-devel

CVSROOT:	/cvs/dm
Module name:	device-mapper
Changes by:	agk@sourceware.org	2008-06-25 19:52:52

Modified files:
	.              : WHATS_NEW 
	lib            : libdm-report.c 

Log message:
	Underline longer report help text headings.

Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/WHATS_NEW.diff?cvsroot=dm&r1=1.247&r2=1.248
http://sourceware.org/cgi-bin/cvsweb.cgi/device-mapper/lib/libdm-report.c.diff?cvsroot=dm&r1=1.22&r2=1.23

--- device-mapper/WHATS_NEW	2008/06/25 14:44:00	1.247
+++ device-mapper/WHATS_NEW	2008/06/25 19:52:51	1.248
@@ -1,5 +1,6 @@
 Version 1.02.28 - 
 ================================
+  Underline longer report help text headings.
 
 Version 1.02.27 - 25th June 2008
 ================================
--- device-mapper/lib/libdm-report.c	2008/06/25 00:10:36	1.22
+++ device-mapper/lib/libdm-report.c	2008/06/25 19:52:52	1.23
@@ -267,8 +267,7 @@
 			log_warn("%s Fields", desc);
 			log_warn("%*.*s", (int) strlen(desc) + 7,
 				 (int) strlen(desc) + 7,
-				 "------------------------------------------");
-				  
+				 "-------------------------------------------------------------------------------");
 		}
 
 		/* FIXME Add line-wrapping at terminal width (or 80 cols) */

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2008-06-25 19:52 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-06-25 19:52 device-mapper ./WHATS_NEW lib/libdm-report.c agk
  -- strict thread matches above, loose matches on Subject: below --
2008-01-20  1:14 agk
2007-04-27 15:22 agk
2007-04-19 20:24 agk
2007-01-18 22:15 agk

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.