]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
fdisk: fix printf stuff
authorKarel Zak <kzak@redhat.com>
Tue, 15 Oct 2013 10:46:35 +0000 (12:46 +0200)
committerKarel Zak <kzak@redhat.com>
Tue, 15 Oct 2013 10:46:35 +0000 (12:46 +0200)
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 <kzak@redhat.com>
fdisks/fdisk-menu.c
fdisks/fdisk.c
libfdisk/src/ask.c
libfdisk/src/bsd.c
libfdisk/src/dos.c
libfdisk/src/gpt.c
libfdisk/src/libfdisk.h
libfdisk/src/sun.c

index f9cce60fc03d840ca14abb0907d36efe4af759ed..e4c64691e421e7f2234c32b772fe9d130bf317ff 100644 (file)
@@ -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);
index 5df78f6a5b8ff4e3c4d7c1c85209b58187254b7c..01e8149ab92c9887254748bf82fd2219bbac2d76 100644 (file)
@@ -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))
index 1d361b9700c981b89a8437c408d0989ad761f897..dd152a1f0cf27f5d6f7dec5b8d2d1065ff572231 100644 (file)
@@ -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;
 }
 
index 91826bce1fca0274d9bf5624218c2ccee0d7319a..ca55a13a9acfca14399ad3d8a42d0bce2afc7c26 100644 (file)
@@ -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;
 }
 
index 0456ba5f2f0dd4f84efae6a989856e81c50c3515..40c05af13cce55df44d1d67f546dd0d3592fa14b 100644 (file)
@@ -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);
index 0692d158eae2d59c69999e006a96665479b6955c..80d4f3c1b3075b9e288c98b04c15d9e21baee715 100644 (file)
@@ -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);
 
index cd856d70d792961c9acd13fca66bb9f6428d7cf5..096bb1fdd8c34506772cec8d6ceefe4b925a52fa 100644 (file)
@@ -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);
index 07485b137c919b1fc4d435c48edfac72f1ebdc31..d5a0af2a6371adfa584f7cf85ac373dfbd07bb25 100644 (file)
@@ -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)