1
0
mirror of git://sourceware.org/git/lvm2.git synced 2024-12-21 13:34:40 +03:00
lvm2/lib/device
David Teigland 96b777167c cov: clean up pvid and vgid usage
pvid and vgid are sometimes a null-terminated string, and
other times a 'struct id', and the two types were often
cast between each other.  When a struct id was cast to a char
pointer, the resulting string would not necessarily be null
terminated.  Casting a null-terminated string id to a
struct id is fine, but is still avoided when possible.

A struct id is:  int8_t uuid[ID_LEN]
A string id is:  char pvid[ID_LEN + 1]

A convention is introduced to help distinguish them:

- variables and struct fields named "pvid" or "vgid"
  should be null-terminated strings.

- variables and struct fields named "pv_id" or "vg_id"
  should be struct id's.

- examples:
  char pvid[ID_LEN + 1];
  char vgid[ID_LEN + 1];
  struct id pv_id;
  struct id vg_id;

Function names also attempt to follow this convention.

Avoid casting between the two types as much as possible,
with limited exceptions when known to be safe and clearly
commented.

Avoid using variations of strcpy and strcmp, and instead
use memcpy/memcmp with ID_LEN (with similar limited
exceptions possible.)
2021-08-16 11:31:15 -05:00
..
bcache-utils.c bcache: use indirection table for fd 2020-09-18 15:10:11 -05:00
bcache.c cov: void unused result 2021-03-15 11:13:24 +01:00
bcache.h bcache: use indirection table for fd 2020-09-18 15:10:11 -05:00
dev-cache.c pvscan: only match devices file for command args 2021-08-05 13:20:26 -05:00
dev-cache.h pvscan: only match devices file for command args 2021-08-05 13:20:26 -05:00
dev-dasd.c cov: mask uninitialized value 2021-03-10 01:34:27 +01:00
dev-ext-udev-constants.h dev-type: check for DEVLINKS udev db variable existence if udev_device_get_is_initialized fn is not present 2016-09-06 13:21:29 +02:00
dev-ext.c build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
dev-io.c cov: mask uninitialized value 2021-03-10 01:34:27 +01:00
dev-luks.c devices: rework libudev usage 2021-07-13 11:11:23 -05:00
dev-lvm1-pool.c build: Don't generate symlinks in include/ dir 2018-05-14 10:30:20 +01:00
dev-md.c devices: rework libudev usage 2021-07-13 11:11:23 -05:00
dev-mpath.c cov: dev-mpath: check config_wwids_file 2021-07-28 00:49:28 +02:00
dev-swap.c devices: rework libudev usage 2021-07-13 11:11:23 -05:00
dev-type.c cov: add initilizer 2021-07-28 00:49:28 +02:00
dev-type.h devices: rework libudev usage 2021-07-13 11:11:23 -05:00
device_id.c cov: clean up pvid and vgid usage 2021-08-16 11:31:15 -05:00
device_id.h devices: rework libudev usage 2021-07-13 11:11:23 -05:00
device-types.h devices: Recognise Veritas Dynamic Multipathing 2017-01-10 22:23:23 +00:00
device.h devices: rework libudev usage 2021-07-13 11:11:23 -05:00