From b443c1779e39bb056b6045b81ba655c875b45747 Mon Sep 17 00:00:00 2001 From: Philip Prindeville Date: Mon, 28 Aug 2017 13:20:55 -0600 Subject: misc: replace magic number 37 with UUID_STR_LEN Signed-off-by: Philip Prindeville --- libblkid/src/partitions/dos.c | 2 +- libblkid/src/partitions/partitions.c | 8 ++++---- libblkid/src/partitions/partitions.h | 4 ++++ libblkid/src/superblocks/superblocks.c | 2 +- libblkid/src/superblocks/superblocks.h | 4 ++++ 5 files changed, 14 insertions(+), 6 deletions(-) (limited to 'libblkid') diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c index 30e3e9e73..1db238781 100644 --- a/libblkid/src/partitions/dos.c +++ b/libblkid/src/partitions/dos.c @@ -177,7 +177,7 @@ static int probe_dos_pt(blkid_probe pr, struct dos_partition *p0, *p; unsigned char *data; uint32_t start, size, id; - char idstr[37]; + char idstr[UUID_STR_LEN]; data = blkid_probe_get_sector(pr, 0); diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 626e11729..d8fc8e3c8 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -166,7 +166,7 @@ struct blkid_struct_parttable { uint64_t offset; /* begin of the partition table (in bytes) */ int nparts; /* number of partitions */ blkid_partition parent; /* parent of nested partition table */ - char id[37]; /* PT identifier (e.g. UUID for GPT) */ + char id[UUID_STR_LEN]; /* PT identifier (e.g. UUID for GPT) */ struct list_head t_tabs; /* all tables */ }; @@ -177,12 +177,12 @@ struct blkid_struct_partition { uint64_t size; /* size of the partitions (512-bytes sectors) */ int type; /* partition type */ - char typestr[37]; /* partition type string (GPT and Mac) */ + char typestr[UUID_STR_LEN]; /* partition type string (GPT and Mac) */ unsigned long long flags; /* partition flags / attributes */ int partno; /* partition number */ - char uuid[37]; /* UUID (when supported by PT), e.g GPT */ + char uuid[UUID_STR_LEN]; /* UUID (when supported by PT), e.g GPT */ unsigned char name[128]; /* Partition in UTF8 name (when supported by PT), e.g. Mac */ blkid_parttable tab; /* partition table */ @@ -1122,7 +1122,7 @@ int blkid_partitions_set_ptuuid(blkid_probe pr, unsigned char *uuid) if (!v) return -ENOMEM; - v->len = 37; + v->len = UUID_STR_LEN; v->data = calloc(1, v->len); if (v->data) { blkid_unparse_uuid(uuid, (char *) v->data, v->len); diff --git a/libblkid/src/partitions/partitions.h b/libblkid/src/partitions/partitions.h index 1d99fb6a3..5ed2681e3 100644 --- a/libblkid/src/partitions/partitions.h +++ b/libblkid/src/partitions/partitions.h @@ -4,6 +4,10 @@ #include "blkidP.h" #include "pt-mbr.h" +#ifndef UUID_STR_LEN +#define UUID_STR_LEN 37 +#endif + extern int blkid_partitions_get_flags(blkid_probe pr); extern blkid_parttable blkid_partlist_new_parttable(blkid_partlist ls, diff --git a/libblkid/src/superblocks/superblocks.c b/libblkid/src/superblocks/superblocks.c index e631e90ac..6b025ee1f 100644 --- a/libblkid/src/superblocks/superblocks.c +++ b/libblkid/src/superblocks/superblocks.c @@ -768,7 +768,7 @@ int blkid_probe_set_uuid_as(blkid_probe pr, unsigned char *uuid, const char *nam if (!v) return -ENOMEM; - v->len = 37; + v->len = UUID_STR_LEN; v->data = calloc(1, v->len); if (!v->data) rc = -ENOMEM; diff --git a/libblkid/src/superblocks/superblocks.h b/libblkid/src/superblocks/superblocks.h index 695c3b783..3dea7b881 100644 --- a/libblkid/src/superblocks/superblocks.h +++ b/libblkid/src/superblocks/superblocks.h @@ -9,6 +9,10 @@ #include "blkidP.h" +#ifndef UUID_STR_LEN +#define UUID_STR_LEN 37 +#endif + extern const struct blkid_idinfo cramfs_idinfo; extern const struct blkid_idinfo swap_idinfo; extern const struct blkid_idinfo swsuspend_idinfo; -- cgit v1.2.3-55-g7522