]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libblkid,libmount: Do not use void* in calculations [cppcheck]
authorBoris Egorov <egorov@linux.com>
Tue, 19 Jan 2016 05:42:26 +0000 (11:42 +0600)
committerBoris Egorov <egorov@linux.com>
Tue, 19 Jan 2016 06:59:12 +0000 (12:59 +0600)
[libblkid/src/superblocks/zfs.c:179]: (portability) 'label' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined.
[libblkid/src/superblocks/zfs.c:237]: (portability) 'label' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.
[libblkid/src/topology/topology.c:221]: (portability) 'chn.data' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.
[libmount/src/fs.c:153]: (portability) 'old' is of type 'const void *'. When using void pointers in calculations, the behaviour is undefined.
[libmount/src/fs.c:154]: (portability) 'new' is of type 'void *'. When using void pointers in calculations, the behaviour is undefined.

libblkid/src/superblocks/zfs.c
libblkid/src/topology/topology.c
libmount/src/fs.c

index 2804b151d9cf9ccb400055b003d5ec6f42ef89cd..c505a720431fc8c429ef9d14c57d043d1260aed2 100644 (file)
@@ -176,7 +176,7 @@ static int find_uberblocks(const void *label, loff_t *ub_offset, int *swap_endia
        loff_t offset = VDEV_LABEL_UBERBLOCK;
 
        for (i = 0; i < UBERBLOCKS_COUNT; i++, offset += UBERBLOCK_SIZE) {
-               ub = (struct zfs_uberblock *)(label + offset);
+               ub = (struct zfs_uberblock *)((char *) label + offset);
 
                if (ub->ub_magic == UBERBLOCK_MAGIC) {
                        *ub_offset = offset;
@@ -234,7 +234,7 @@ static int probe_zfs(blkid_probe pr, const struct blkid_idmag *mag)
 
                if (found_in_label > 0) {
                        found+= found_in_label;
-                       ub = (struct zfs_uberblock *)(label + ub_offset);
+                       ub = (struct zfs_uberblock *)((char *) label + ub_offset);
                        ub_offset += offset;
 
                        if (found >= ZFS_WANT)
index 88747241497e53997dcd77ba94d02e4d17f90002..f434aebc6b0ebe2c73d4a6138d572943f453a54a 100644 (file)
@@ -218,7 +218,7 @@ static int topology_set_value(blkid_probe pr, const char *name,
                return 0;       /* ignore zeros */
 
        if (chn->binary) {
-               memcpy(chn->data + structoff, &data, sizeof(data));
+               memcpy((char *) chn->data + structoff, &data, sizeof(data));
                return 0;
        }
        return blkid_probe_sprintf_value(pr, name, "%lu", data);
index e3b4eee0e630c8756519df6ae03321283ad68ff8..2bab7d6af6db5ff74d80b0049fa3b21264ec8391 100644 (file)
@@ -150,8 +150,8 @@ static inline int update_str(char **dest, const char *src)
 
 static inline int cpy_str_at_offset(void *new, const void *old, size_t offset)
 {
-       char **o = (char **) (old + offset);
-       char **n = (char **) (new + offset);
+       char **o = (char **) ((char *) old + offset);
+       char **n = (char **) ((char *) new + offset);
 
        if (*n)
                return 0;       /* already set, don't overwrite */