From: Karel Zak Date: Tue, 15 Oct 2013 10:46:35 +0000 (+0200) Subject: fdisk: fix printf stuff X-Git-Tag: v2.24~28 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=e39966c6a026003f88989e5469fa9b3682fcfbc6;p=thirdparty%2Futil-linux.git fdisk: fix printf stuff Unfortunately, fdisk_warn/info/.. function was not marked by printf __attribute__. We don't want to break gettext stuff now, so all compiler warnings have been fixed by casts. This is temporary solution, after release it will be necessary to fix all the strings. Signed-off-by: Karel Zak --- diff --git a/fdisks/fdisk-menu.c b/fdisks/fdisk-menu.c index f9cce60fc0..e4c64691e4 100644 --- a/fdisks/fdisk-menu.c +++ b/fdisks/fdisk-menu.c @@ -456,9 +456,9 @@ static int generic_menu_cb(struct fdisk_context **cxt0, if (!rc) rc = fdisk_delete_partition(cxt, n); if (rc) - fdisk_warnx(cxt, _("Could not delete partition %d"), n + 1); + fdisk_warnx(cxt, _("Could not delete partition %d"), (int) n + 1); else - fdisk_info(cxt, _("Partition %d has been deleted."), n + 1); + fdisk_info(cxt, _("Partition %d has been deleted."), (int) n + 1); break; case 'l': list_partition_types(cxt); diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c index 5df78f6a5b..01e8149ab9 100644 --- a/fdisks/fdisk.c +++ b/fdisks/fdisk.c @@ -200,7 +200,9 @@ void list_disk_geometry(struct fdisk_context *cxt) | SIZE_SUFFIX_3LETTER, bytes); fdisk_colon(cxt, _("Disk %s: %s, %llu bytes, %llu sectors"), - cxt->dev_path, strsz, bytes, cxt->total_sectors); + cxt->dev_path, strsz, + (unsigned long long) bytes, + (unsigned long long) cxt->total_sectors); free(strsz); if (fdisk_require_geometry(cxt) || fdisk_context_use_cylinders(cxt)) diff --git a/libfdisk/src/ask.c b/libfdisk/src/ask.c index 1d361b9700..dd152a1f0c 100644 --- a/libfdisk/src/ask.c +++ b/libfdisk/src/ask.c @@ -237,15 +237,15 @@ static char *mk_string_list(char *ptr, size_t *len, size_t *begin, /* add to the list */ if (!*run) rlen = inchar ? snprintf(ptr, *len, "%c,", tochar(*begin)) : - snprintf(ptr, *len, "%zd,", *begin); + snprintf(ptr, *len, "%zu,", *begin); else if (*run == 1) rlen = inchar ? snprintf(ptr, *len, "%c,%c,", tochar(*begin), tochar(*begin + 1)) : - snprintf(ptr, *len, "%zd,%zd,", *begin, *begin + 1); + snprintf(ptr, *len, "%zu,%zu,", *begin, *begin + 1); else rlen = inchar ? snprintf(ptr, *len, "%c-%c,", tochar(*begin), tochar(*begin + *run)) : - snprintf(ptr, *len, "%zd-%zd,", *begin, *begin + *run); + snprintf(ptr, *len, "%zu-%zu,", *begin, *begin + *run); if (rlen < 0 || (size_t) rlen + 1 > *len) return NULL; @@ -286,7 +286,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew) inchar = 1; DBG(ASK, dbgprint("%s: asking for %s partition number " - "(max: %zd, inchar: %s)", + "(max: %zu, inchar: %s)", cxt->label->name, wantnew ? "new" : "used", cxt->label->nparts_max, @@ -324,14 +324,14 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew) } } - DBG(ASK, dbgprint("ask limits: low: %zd, high: %zd, default: %zd", + DBG(ASK, dbgprint("ask limits: low: %ju, high: %ju, default: %ju", num->low, num->hig, num->dfl)); if (!rc && !wantnew && num->low == num->hig) { if (num->low > 0) { /* only one existing partiton, don't ask, return the number */ fdisk_ask_number_set_result(ask, num->low); - fdisk_info(cxt, _("Selected partition %d"), num->low); + fdisk_info(cxt, _("Selected partition %d"), (int) num->low); } else if (num->low == 0) { fdisk_warnx(cxt, _("No partition is defined yet!")); @@ -343,7 +343,7 @@ int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew) if (num->low > 0) { /* only one free partition, don't ask, return the number */ fdisk_ask_number_set_result(ask, num->low); - fdisk_info(cxt, _("Selected partition %d"), num->low); + fdisk_info(cxt, _("Selected partition %d"), (int) num->low); } if (num->low == 0) { fdisk_warnx(cxt, _("No free partition available!")); @@ -366,7 +366,7 @@ dont_ask: if (*partnum) *partnum -= 1; } - DBG(ASK, dbgprint("result: %zd [rc=%d]\n", fdisk_ask_number_get_result(ask), rc)); + DBG(ASK, dbgprint("result: %ju [rc=%d]\n", fdisk_ask_number_get_result(ask), rc)); fdisk_free_ask(ask); return rc; } @@ -403,7 +403,7 @@ int fdisk_ask_number(struct fdisk_context *cxt, *result = fdisk_ask_number_get_result(ask); fdisk_free_ask(ask); - DBG(ASK, dbgprint("result: %zd [rc=%d]\n", *result, rc)); + DBG(ASK, dbgprint("result: %ju [rc=%d]\n", *result, rc)); return rc; } diff --git a/libfdisk/src/bsd.c b/libfdisk/src/bsd.c index 91826bce1f..ca55a13a9a 100644 --- a/libfdisk/src/bsd.c +++ b/libfdisk/src/bsd.c @@ -838,7 +838,7 @@ int fdisk_bsd_link_partition(struct fdisk_context *cxt) fdisk_sinfo(cxt, FDISK_INFO_SUCCESS, _("BSD partition '%c' linked to DOS partition %d."), - 'a' + i, k + 1); + 'a' + (int) i, (int) k + 1); return 0; } diff --git a/libfdisk/src/dos.c b/libfdisk/src/dos.c index 0456ba5f2f..40c05af13c 100644 --- a/libfdisk/src/dos.c +++ b/libfdisk/src/dos.c @@ -296,8 +296,8 @@ static void dos_init(struct fdisk_context *cxt) "partition table format can not be used on drives for " "volumes larger than (%llu bytes) for %ld-byte " "sectors. Use GUID partition table format (GPT)."), - szstr, bytes, - (sector_t ) UINT_MAX * cxt->sector_size, + szstr, (unsigned long long) bytes, + (unsigned long long) UINT_MAX * cxt->sector_size, cxt->sector_size); free(szstr); } @@ -809,7 +809,8 @@ static int add_partition(struct fdisk_context *cxt, int n, struct fdisk_parttype if (p && p->sys_ind) { fdisk_warnx(cxt, _("Partition %zd is already defined. " - "Delete it before re-adding it."), n + 1); + "Delete it before re-adding it."), + (ssize_t) n + 1); return -EINVAL; } fill_bounds(cxt, first, last); @@ -1926,7 +1927,7 @@ static int dos_toggle_partition_flag( case DOS_FLAG_ACTIVE: if (IS_EXTENDED(p->sys_ind) && !p->boot_ind) fdisk_warnx(cxt, _("Partition %d: is an extended " - "partition."), i + 1); + "partition."), (int) i + 1); p->boot_ind = (p->boot_ind ? 0 : ACTIVE_FLAG); partition_set_changed(cxt, i, 1); diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c index 0692d158ea..80d4f3c1b3 100644 --- a/libfdisk/src/gpt.c +++ b/libfdisk/src/gpt.c @@ -42,7 +42,7 @@ #define EFI_PMBR_OSTYPE 0xEE #define MSDOS_MBR_SIGNATURE 0xAA55 -#define GPT_PART_NAME_LEN 72 / sizeof(uint16_t) +#define GPT_PART_NAME_LEN (72 / sizeof(uint16_t)) #define GPT_NPARTITIONS 128 /* Globally unique identifier */ @@ -1202,7 +1202,7 @@ static int gpt_list_disklabel(struct fdisk_context *cxt) fdisk_colon(cxt, _("Last LBA: %ju"), h->last_usable_lba); fdisk_colon(cxt, _("Alternative LBA: %ju"), h->alternative_lba); fdisk_colon(cxt, _("Partitions entries LBA: %ju"), h->partition_entry_lba); - fdisk_colon(cxt, _("Allocated partition entries: %ju"), h->npartition_entries); + fdisk_colon(cxt, _("Allocated partition entries: %ju"), (uintmax_t) h->npartition_entries); } tt_define_column(tb, _("Device"), 0.1, 0); tt_define_column(tb, _("Start"), 12, TT_FL_RIGHT); @@ -2052,7 +2052,7 @@ int fdisk_gpt_partition_set_name(struct fdisk_context *cxt, size_t i) fdisk_sinfo(cxt, FDISK_INFO_SUCCESS, _("Partition name changed from '%s' to '%.*s'."), - old, GPT_PART_NAME_LEN, str); + old, (int) GPT_PART_NAME_LEN, str); free(str); free(old); diff --git a/libfdisk/src/libfdisk.h b/libfdisk/src/libfdisk.h index cd856d70d7..096bb1fdd8 100644 --- a/libfdisk/src/libfdisk.h +++ b/libfdisk/src/libfdisk.h @@ -255,12 +255,17 @@ extern int fdisk_ask_yesno(struct fdisk_context *cxt, const char *query, int *re extern uint64_t fdisk_ask_yesno_get_result(struct fdisk_ask *ask); extern int fdisk_ask_yesno_set_result(struct fdisk_ask *ask, uint64_t result); -extern int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...); -extern int fdisk_colon(struct fdisk_context *cxt, const char *fmt, ...); -extern int fdisk_sinfo(struct fdisk_context *cxt, unsigned int flags, const char *fmt, ...); - -extern int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...); -extern int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...); +extern int fdisk_info(struct fdisk_context *cxt, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int fdisk_colon(struct fdisk_context *cxt, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int fdisk_sinfo(struct fdisk_context *cxt, unsigned int flags, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 3, 4))); + +extern int fdisk_warnx(struct fdisk_context *cxt, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); +extern int fdisk_warn(struct fdisk_context *cxt, const char *fmt, ...) + __attribute__ ((__format__ (__printf__, 2, 3))); extern int fdisk_ask_print_get_errno(struct fdisk_ask *ask); extern int fdisk_ask_print_set_errno(struct fdisk_ask *ask, int errnum); diff --git a/libfdisk/src/sun.c b/libfdisk/src/sun.c index 07485b137c..d5a0af2a63 100644 --- a/libfdisk/src/sun.c +++ b/libfdisk/src/sun.c @@ -618,8 +618,8 @@ static int sun_add_partition( _("You haven't covered the whole disk with the 3rd partition, but your value\n" "%d %s covers some other partition. Your entry has been changed\n" "to %d %s"), - fdisk_scround(cxt, last), fdisk_context_get_unit(cxt, SINGULAR), - fdisk_scround(cxt, stop), fdisk_context_get_unit(cxt, SINGULAR)); + (int) fdisk_scround(cxt, last), fdisk_context_get_unit(cxt, SINGULAR), + (int) fdisk_scround(cxt, stop), fdisk_context_get_unit(cxt, SINGULAR)); last = stop; } } else if (!whole_disk && last > stop)