From db3c1ac1c83ba999cffaadb7800d26868773af76 Mon Sep 17 00:00:00 2001 From: Alasdair Kergon Date: Fri, 2 Jul 2010 21:16:50 +0000 Subject: [PATCH] Add printf format attributes to yes_no_prompt & dm_{sn,as}printf and fix a calle --- WHATS_NEW | 1 + WHATS_NEW_DM | 1 + lib/display/display.h | 2 +- lib/metadata/mirror.c | 2 +- libdm/libdevmapper.h | 7 +++++-- libdm/libdm-deptree.c | 12 ++++++------ 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/WHATS_NEW b/WHATS_NEW index d7cd89675..c0619efa2 100644 --- a/WHATS_NEW +++ b/WHATS_NEW @@ -1,5 +1,6 @@ Version 2.02.70 - ================================ + Add printf format attributes to yes_no_prompt and fix a caller. Always pass unsuspended dm devices through persistent filter to other filters. Move test for suspended dm devices ahead of other filters. Fix another segfault in clvmd -R if no response from daemon received. (2.02.68) diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM index 66ba00a52..7f78128c4 100644 --- a/WHATS_NEW_DM +++ b/WHATS_NEW_DM @@ -1,5 +1,6 @@ Version 1.02.52 - ================================ + Add printf format attributes to dm_{sn,as}printf and fix a caller. Move dmeventd man page from install_lvm2 to install_device-mapper. (1.02.50) Version 1.02.51 - 30th June 2010 diff --git a/lib/display/display.h b/lib/display/display.h index 4831affea..03cef4167 100644 --- a/lib/display/display.h +++ b/lib/display/display.h @@ -59,6 +59,6 @@ void display_segtypes(const struct cmd_context *cmd); const char *get_alloc_string(alloc_policy_t alloc); alloc_policy_t get_alloc_from_string(const char *str); -char yes_no_prompt(const char *prompt, ...); +char yes_no_prompt(const char *prompt, ...) __attribute__ ((format(printf, 1, 2))); #endif diff --git a/lib/metadata/mirror.c b/lib/metadata/mirror.c index bbdbe323a..80436f93f 100644 --- a/lib/metadata/mirror.c +++ b/lib/metadata/mirror.c @@ -1543,7 +1543,7 @@ int remove_mirror_log(struct cmd_context *cmd, return 0; } else if (yes_no_prompt("Full resync required to convert " "inactive mirror %s to core log. " - "Proceed? [y/n]: ") == 'y') + "Proceed? [y/n]: ", lv->name) == 'y') sync_percent = 0; else return 0; diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h index 78a8e361c..8026c7bfd 100644 --- a/libdm/libdevmapper.h +++ b/libdm/libdevmapper.h @@ -66,6 +66,7 @@ void dm_log_init_verbose(int level); typedef void (*dm_log_fn) (int level, const char *file, int line, const char *f, ...) __attribute__ ((format(printf, 4, 5))); + void dm_log_init(dm_log_fn fn); /* * For backward-compatibility, indicate that dm_log_init() was used @@ -943,7 +944,8 @@ int dm_split_words(char *buffer, unsigned max, /* * Returns -1 if buffer too small */ -int dm_snprintf(char *buf, size_t bufsize, const char *format, ...); +int dm_snprintf(char *buf, size_t bufsize, const char *format, ...) + __attribute__ ((format(printf, 3, 4))); /* * Returns pointer to the last component of the path. @@ -975,7 +977,8 @@ int dm_fclose(FILE *stream); * Pointer to the buffer is stored in *buf. * Returns -1 on failure leaving buf undefined. */ -int dm_asprintf(char **buf, const char *format, ...); +int dm_asprintf(char **buf, const char *format, ...) + __attribute__ ((format(printf, 2, 3))); /********************* * regular expressions diff --git a/libdm/libdm-deptree.c b/libdm/libdm-deptree.c index f9d9a29ca..fac9d213e 100644 --- a/libdm/libdm-deptree.c +++ b/libdm/libdm-deptree.c @@ -1442,7 +1442,7 @@ static int _emit_areas_line(struct dm_task *dmt __attribute((unused)), struct seg_area *area; char devbuf[DM_FORMAT_DEV_BUFSIZE]; unsigned first_time = 1; - const char *logtype; + const char *logtype, *synctype; unsigned log_parm_count; dm_list_iterate_items(area, &seg->areas) { @@ -1475,12 +1475,12 @@ static int _emit_areas_line(struct dm_task *dmt __attribute((unused)), EMIT_PARAMS(*pos, " %s %u%s %" PRIu64, logtype, log_parm_count, devbuf, area->region_size); - logtype = (area->flags & DM_NOSYNC) ? - " nosync" : (area->flags & DM_FORCESYNC) ? - " sync" : NULL; + synctype = (area->flags & DM_NOSYNC) ? + " nosync" : (area->flags & DM_FORCESYNC) ? + " sync" : NULL; - if (logtype) - EMIT_PARAMS(*pos, logtype); + if (synctype) + EMIT_PARAMS(*pos, "%s", synctype); } break; default: -- 2.43.5