diff options
author | Karel Zak | 2015-04-22 11:08:05 +0200 |
---|---|---|
committer | Karel Zak | 2015-04-22 11:08:05 +0200 |
commit | 40b175084ff4c57468fb67600c8c66703e17cd75 (patch) | |
tree | 25ed8dc26b4afc906bfcc1e58c6be37b687f6eea /include/strutils.h | |
parent | fdisk, sfdisk: fix -o <list> backend (diff) | |
download | kernel-qcow2-util-linux-40b175084ff4c57468fb67600c8c66703e17cd75.tar.gz kernel-qcow2-util-linux-40b175084ff4c57468fb67600c8c66703e17cd75.tar.xz kernel-qcow2-util-linux-40b175084ff4c57468fb67600c8c66703e17cd75.zip |
lib/strutils: fix string_add_to_idarray() int vs. size_t
The function uses "int" as argument, but for array size (and index) is better
to use unsigned type (size_t). If we mix "size_t" in util (e.g. fdisk)
and "int" in lib/strutils.c then result is unexpected behavior on
ppc64.
# sfdisk --list -o DEVICE,START,SIZE /dev/sdb
Disk /dev/sdb: 50 MiB, 52428800 bytes, 102400 sectors
Units: sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 4096 bytes
I/O size (minimum/optimal): 4096 bytes / 32768 bytes
Disklabel type: gpt
Disk identifier: 3B8559DB-33AF-43E9-BEFC-C331D829B539
lt-sfdisk: libfdisk/src/label.c:178: fdisk_label_get_field: Assertion `id > 0' failed.
The patch cleanup all code to use size_t everywhere.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'include/strutils.h')
-rw-r--r-- | include/strutils.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/strutils.h b/include/strutils.h index 847a4219f..8235b5017 100644 --- a/include/strutils.h +++ b/include/strutils.h @@ -92,7 +92,7 @@ extern char *size_to_human_string(int options, uint64_t bytes); extern int string_to_idarray(const char *list, int ary[], size_t arysz, int (name2id)(const char *, size_t)); extern int string_add_to_idarray(const char *list, int ary[], - size_t arysz, int *ary_pos, + size_t arysz, size_t *ary_pos, int (name2id)(const char *, size_t)); extern int string_to_bitarray(const char *list, char *ary, |