From 8bb05ac73a5b448b339ce0bc8d396c82c459b47f Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 14 Apr 2024 21:33:32 +0200 Subject: Merging upstream version 2.40. Signed-off-by: Daniel Baumann --- libblkid/src/partitions/bsd.c | 2 +- libblkid/src/partitions/dos.c | 14 +++++++------- libblkid/src/partitions/gpt.c | 6 +++--- libblkid/src/partitions/mac.c | 2 +- libblkid/src/partitions/minix.c | 4 ++-- libblkid/src/partitions/partitions.c | 5 +++-- libblkid/src/partitions/ultrix.c | 6 +++--- 7 files changed, 20 insertions(+), 19 deletions(-) (limited to 'libblkid/src/partitions') diff --git a/libblkid/src/partitions/bsd.c b/libblkid/src/partitions/bsd.c index ba12019..20dab6b 100644 --- a/libblkid/src/partitions/bsd.c +++ b/libblkid/src/partitions/bsd.c @@ -47,7 +47,7 @@ static int probe_bsd_pt(blkid_probe pr, const struct blkid_idmag *mag) blkid_partition parent; blkid_partlist ls; int i, nparts = BSD_MAXPARTITIONS; - unsigned char *data; + const unsigned char *data; int rc = BLKID_PROBE_NONE; uint32_t abs_offset = 0; diff --git a/libblkid/src/partitions/dos.c b/libblkid/src/partitions/dos.c index 5c7718c..d5a8aa3 100644 --- a/libblkid/src/partitions/dos.c +++ b/libblkid/src/partitions/dos.c @@ -34,7 +34,7 @@ static const struct dos_subtypes { { MBR_MINIX_PARTITION, &minix_pt_idinfo } }; -static inline int is_extended(struct dos_partition *p) +static inline int is_extended(const struct dos_partition *p) { return (p->sys_ind == MBR_DOS_EXTENDED_PARTITION || p->sys_ind == MBR_W95_EXTENDED_PARTITION || @@ -46,7 +46,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab, { blkid_partlist ls = blkid_probe_get_partlist(pr); uint32_t cur_start = ex_start, cur_size = ex_size; - unsigned char *data; + const unsigned char *data; int ct_nodata = 0; /* count ext.partitions without data partitions */ int i; @@ -57,7 +57,7 @@ static int parse_dos_extended(blkid_probe pr, blkid_parttable tab, } while (1) { - struct dos_partition *p, *p0; + const struct dos_partition *p, *p0; uint32_t start = 0, size; if (++ct_nodata > 100) @@ -156,9 +156,9 @@ static inline int is_lvm(blkid_probe pr) return (v && v->data && strcmp((char *) v->data, "LVM2_member") == 0); } -static inline int is_empty_mbr(unsigned char *mbr) +static inline int is_empty_mbr(const unsigned char *mbr) { - struct dos_partition *p = mbr_get_partition(mbr, 0); + const struct dos_partition *p = mbr_get_partition(mbr, 0); int i, nparts = 0; for (i = 0; i < 4; i++) { @@ -177,8 +177,8 @@ static int probe_dos_pt(blkid_probe pr, int ssf; blkid_parttable tab = NULL; blkid_partlist ls; - struct dos_partition *p0, *p; - unsigned char *data; + const struct dos_partition *p0, *p; + const unsigned char *data; uint32_t start, size, id; char idstr[UUID_STR_LEN]; diff --git a/libblkid/src/partitions/gpt.c b/libblkid/src/partitions/gpt.c index 89e7bb6..473bf5c 100644 --- a/libblkid/src/partitions/gpt.c +++ b/libblkid/src/partitions/gpt.c @@ -109,7 +109,7 @@ static inline uint32_t count_crc32(const unsigned char *buf, size_t len, return (ul_crc32_exclude_offset(~0L, buf, len, exclude_off, exclude_len) ^ ~0L); } -static inline unsigned char *get_lba_buffer(blkid_probe pr, +static inline const unsigned char *get_lba_buffer(blkid_probe pr, uint64_t lba, size_t bytes) { return blkid_probe_get_buffer(pr, @@ -161,8 +161,8 @@ static int last_lba(blkid_probe pr, uint64_t *lba) static int is_pmbr_valid(blkid_probe pr, int *has) { int flags = blkid_partitions_get_flags(pr); - unsigned char *data; - struct dos_partition *p; + const unsigned char *data; + const struct dos_partition *p; int i; if (has) diff --git a/libblkid/src/partitions/mac.c b/libblkid/src/partitions/mac.c index 75a558b..36ce74e 100644 --- a/libblkid/src/partitions/mac.c +++ b/libblkid/src/partitions/mac.c @@ -56,7 +56,7 @@ struct mac_driver_desc { /* there is more stuff after this that we don't need */ } __attribute__((packed)); -static inline unsigned char *get_mac_block( +static inline const unsigned char *get_mac_block( blkid_probe pr, uint16_t block_size, uint32_t num) diff --git a/libblkid/src/partitions/minix.c b/libblkid/src/partitions/minix.c index 43c9d9a..dee7df9 100644 --- a/libblkid/src/partitions/minix.c +++ b/libblkid/src/partitions/minix.c @@ -17,11 +17,11 @@ static int probe_minix_pt(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__))) { - struct dos_partition *p; + const struct dos_partition *p; blkid_parttable tab = NULL; blkid_partition parent; blkid_partlist ls; - unsigned char *data; + const unsigned char *data; int i; data = blkid_probe_get_sector(pr, 0); diff --git a/libblkid/src/partitions/partitions.c b/libblkid/src/partitions/partitions.c index 8ebf480..e096cf8 100644 --- a/libblkid/src/partitions/partitions.c +++ b/libblkid/src/partitions/partitions.c @@ -436,8 +436,8 @@ static blkid_partition new_partition(blkid_partlist ls, blkid_parttable tab) /* Linux kernel has DISK_MAX_PARTS=256, but it's too much for * generic Linux machine -- let start with 32 partitions. */ - void *tmp = realloc(ls->parts, (ls->nparts_max + 32) * - sizeof(struct blkid_struct_partition)); + void *tmp = reallocarray(ls->parts, ls->nparts_max + 32, + sizeof(struct blkid_struct_partition)); if (!tmp) return NULL; ls->parts = tmp; @@ -557,6 +557,7 @@ static int idinfo_probe(blkid_probe pr, const struct blkid_idinfo *id, "%s: ---> call probefunc()", id->name)); errno = 0; rc = id->probefunc(pr, mag); + blkid_probe_prune_buffers(pr); if (rc < 0) { /* reset after error */ reset_partlist(blkid_probe_get_partlist(pr)); diff --git a/libblkid/src/partitions/ultrix.c b/libblkid/src/partitions/ultrix.c index 9c060be..a85712f 100644 --- a/libblkid/src/partitions/ultrix.c +++ b/libblkid/src/partitions/ultrix.c @@ -37,8 +37,8 @@ struct ultrix_disklabel { static int probe_ultrix_pt(blkid_probe pr, const struct blkid_idmag *mag __attribute__((__unused__))) { - unsigned char *data; - struct ultrix_disklabel *l; + const unsigned char *data; + const struct ultrix_disklabel *l; blkid_parttable tab = NULL; blkid_partlist ls; int i; @@ -50,7 +50,7 @@ static int probe_ultrix_pt(blkid_probe pr, goto nothing; } - l = (struct ultrix_disklabel *) (data + ULTRIX_OFFSET); + l = (const struct ultrix_disklabel *) (data + ULTRIX_OFFSET); if (l->pt_magic != ULTRIX_MAGIC || l->pt_valid != 1) goto nothing; -- cgit v1.2.3