diff options
author | Boris Egorov | 2016-01-19 06:42:26 +0100 |
---|---|---|
committer | Boris Egorov | 2016-01-19 07:59:12 +0100 |
commit | fef0063119b2e756cdf006d5c089552ca4d964ee (patch) | |
tree | e6f7473ae2d0ad4b5018767fcb192be49dfe3afb | |
parent | libblkid: (zfs) add cast to fix UB [cppcheck] (diff) | |
download | kernel-qcow2-util-linux-fef0063119b2e756cdf006d5c089552ca4d964ee.tar.gz kernel-qcow2-util-linux-fef0063119b2e756cdf006d5c089552ca4d964ee.tar.xz kernel-qcow2-util-linux-fef0063119b2e756cdf006d5c089552ca4d964ee.zip |
libblkid,libmount: Do not use void* in calculations [cppcheck]
[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.
-rw-r--r-- | libblkid/src/superblocks/zfs.c | 4 | ||||
-rw-r--r-- | libblkid/src/topology/topology.c | 2 | ||||
-rw-r--r-- | libmount/src/fs.c | 4 |
3 files changed, 5 insertions, 5 deletions
diff --git a/libblkid/src/superblocks/zfs.c b/libblkid/src/superblocks/zfs.c index 2804b151d..c505a7204 100644 --- a/libblkid/src/superblocks/zfs.c +++ b/libblkid/src/superblocks/zfs.c @@ -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) diff --git a/libblkid/src/topology/topology.c b/libblkid/src/topology/topology.c index 887472414..f434aebc6 100644 --- a/libblkid/src/topology/topology.c +++ b/libblkid/src/topology/topology.c @@ -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); diff --git a/libmount/src/fs.c b/libmount/src/fs.c index e3b4eee0e..2bab7d6af 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -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 */ |