From: Karel Zak Date: Tue, 2 Aug 2011 11:29:29 +0000 (+0200) Subject: libblkid: fix compiler warnings [-Wunused-parameter -Wsign-compare] X-Git-Tag: v2.20-rc2~122 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c9f51c712f952d661b264b4c5ac175a9ac08f60e;p=thirdparty%2Futil-linux.git libblkid: fix compiler warnings [-Wunused-parameter -Wsign-compare] Signed-off-by: Karel Zak --- diff --git a/TODO b/TODO index 0dc74885c7..37a3a273eb 100644 --- a/TODO +++ b/TODO @@ -143,6 +143,9 @@ libblkid - remove strerrr() from debug messages (use %m) to make BLKID_DEBUG= output thread-safe + - (!) don't use internally blkid_loff_t, rather use off_t, size_t, ssize_t, + stdint.h types and so on... + - add - suffix to test images for native-endian filesystems (e.g. swap) and add support for such functionality to tests/ts/blkid/low-probe diff --git a/libblkid/src/blkidP.h b/libblkid/src/blkidP.h index aeeebc1651..61a1aad895 100644 --- a/libblkid/src/blkidP.h +++ b/libblkid/src/blkidP.h @@ -90,7 +90,7 @@ struct blkid_chain { int enabled; /* boolean */ int flags; /* BLKID__* */ int binary; /* boolean */ - int idx; /* index of the current prober */ + int idx; /* index of the current prober (or -1) */ unsigned long *fltr; /* filter or NULL */ void *data; /* private chain data or NULL */ }; @@ -99,7 +99,7 @@ struct blkid_chain { * Chain driver */ struct blkid_chaindrv { - const int id; /* BLKID_CHAIN_* */ + const size_t id; /* BLKID_CHAIN_* */ const char *name; /* name of chain (for debug purpose) */ const int dflt_flags; /* default chain flags */ const int dflt_enabled; /* default enabled boolean */ diff --git a/libblkid/src/devno.c b/libblkid/src/devno.c index 9a356a84f5..92ed7c0259 100644 --- a/libblkid/src/devno.c +++ b/libblkid/src/devno.c @@ -460,10 +460,10 @@ int blkid_driver_has_major(const char *drvname, int major) } while (fgets(buf, sizeof(buf), f)) { - unsigned int maj; + int maj; char name[64]; - if (sscanf(buf, "%u %64[^\n ]", &maj, name) != 2) + if (sscanf(buf, "%d %64[^\n ]", &maj, name) != 2) continue; if (maj == major && strcmp(name, drvname) == 0) { diff --git a/libblkid/src/probe.c b/libblkid/src/probe.c index 3c691cf7d4..7d0c9f9586 100644 --- a/libblkid/src/probe.c +++ b/libblkid/src/probe.c @@ -456,7 +456,7 @@ unsigned long *blkid_probe_get_filter(blkid_probe pr, int chain, int create) */ int __blkid_probe_invert_filter(blkid_probe pr, int chain) { - int i; + size_t i; struct blkid_chain *chn; chn = &pr->chains[chain]; @@ -481,7 +481,7 @@ int __blkid_probe_filter_types(blkid_probe pr, int chain, int flag, char *names[ { unsigned long *fltr; struct blkid_chain *chn; - int i; + size_t i; fltr = blkid_probe_get_filter(pr, chain, TRUE); if (!fltr) @@ -882,10 +882,10 @@ int blkid_do_probe(blkid_probe pr) * the start (chain->idx == -1) */ else if (rc == 1 && (chn->enabled == FALSE || - chn->idx + 1 == chn->driver->nidinfos || + chn->idx + 1 == (int) chn->driver->nidinfos || chn->idx == -1)) { - int idx = chn->driver->id + 1; + size_t idx = chn->driver->id + 1; if (idx < BLKID_NCHAINS) chn = pr->cur_chain = &pr->chains[idx]; @@ -1398,11 +1398,15 @@ struct blkid_prval *__blkid_probe_lookup_value(blkid_probe pr, const char *name) /* converts DCE UUID (uuid[16]) to human readable string * - the @len should be always 37 */ -void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) -{ #ifdef HAVE_LIBUUID +void blkid_unparse_uuid(const unsigned char *uuid, char *str, + size_t len __attribute__((__unused__))) +{ uuid_unparse(uuid, str); +} #else +void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) +{ snprintf(str, len, "%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x", uuid[0], uuid[1], uuid[2], uuid[3], @@ -1410,8 +1414,8 @@ void blkid_unparse_uuid(const unsigned char *uuid, char *str, size_t len) uuid[6], uuid[7], uuid[8], uuid[9], uuid[10], uuid[11], uuid[12], uuid[13], uuid[14],uuid[15]); -#endif } +#endif /* Removes whitespace from the right-hand side of a string (trailing @@ -1464,7 +1468,7 @@ void blkid_probe_set_wiper(blkid_probe pr, blkid_loff_t off, blkid_loff_t size) chn = pr->cur_chain; if (!chn || !chn->driver || - chn->idx < 0 || chn->idx >= chn->driver->nidinfos) + chn->idx < 0 || (size_t) chn->idx >= chn->driver->nidinfos) return; pr->wipe_size = size;