Skip to content

Commit 5f69841

Browse files
arndbgregkh
authored andcommitted
partitions: msdos: fix one-byte get_unaligned()
[ Upstream commit 1b17749 ] A simplification of get_unaligned() clashes with callers that pass in a character pointer, causing a harmless warning like: block/partitions/msdos.c: In function 'msdos_partition': include/asm-generic/unaligned.h:13:22: warning: 'packed' attribute ignored for field of type 'u8' {aka 'unsigned char'} [-Wattributes] Remove the SYS_IND() macro with the get_unaligned() call and just use the ->ind field directly. Signed-off-by: Arnd Bergmann <arnd@arndb.de> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent a8c3d1a commit 5f69841

3 files changed

Lines changed: 12 additions & 17 deletions

File tree

‎block/partitions/ldm.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -510,7 +510,7 @@ static bool ldm_validate_partition_table(struct parsed_partitions *state)
510510

511511
p = (struct msdos_partition *)(data + 0x01BE);
512512
for (i = 0; i < 4; i++, p++)
513-
if (SYS_IND (p) == LDM_PARTITION) {
513+
if (p->sys_ind == LDM_PARTITION) {
514514
result = true;
515515
break;
516516
}

‎block/partitions/ldm.h‎

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,6 @@ struct parsed_partitions;
8484
#define TOC_BITMAP1 "config" /* Names of the two defined */
8585
#define TOC_BITMAP2 "log" /* bitmaps in the TOCBLOCK. */
8686

87-
/* Borrowed from msdos.c */
88-
#define SYS_IND(p) (get_unaligned(&(p)->sys_ind))
89-
9087
struct frag { /* VBLK Fragment handling */
9188
struct list_head list;
9289
u32 group;

‎block/partitions/msdos.c‎

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,6 @@
3838
*/
3939
#include <asm/unaligned.h>
4040

41-
#define SYS_IND(p) get_unaligned(&p->sys_ind)
42-
4341
static inline sector_t nr_sects(struct msdos_partition *p)
4442
{
4543
return (sector_t)get_unaligned_le32(&p->nr_sects);
@@ -52,9 +50,9 @@ static inline sector_t start_sect(struct msdos_partition *p)
5250

5351
static inline int is_extended_partition(struct msdos_partition *p)
5452
{
55-
return (SYS_IND(p) == DOS_EXTENDED_PARTITION ||
56-
SYS_IND(p) == WIN98_EXTENDED_PARTITION ||
57-
SYS_IND(p) == LINUX_EXTENDED_PARTITION);
53+
return (p->sys_ind == DOS_EXTENDED_PARTITION ||
54+
p->sys_ind == WIN98_EXTENDED_PARTITION ||
55+
p->sys_ind == LINUX_EXTENDED_PARTITION);
5856
}
5957

6058
#define MSDOS_LABEL_MAGIC1 0x55
@@ -193,7 +191,7 @@ static void parse_extended(struct parsed_partitions *state,
193191

194192
put_partition(state, state->next, next, size);
195193
set_info(state, state->next, disksig);
196-
if (SYS_IND(p) == LINUX_RAID_PARTITION)
194+
if (p->sys_ind == LINUX_RAID_PARTITION)
197195
state->parts[state->next].flags = ADDPART_FLAG_RAID;
198196
loopct = 0;
199197
if (++state->next == state->limit)
@@ -546,7 +544,7 @@ static void parse_minix(struct parsed_partitions *state,
546544
* a secondary MBR describing its subpartitions, or
547545
* the normal boot sector. */
548546
if (msdos_magic_present(data + 510) &&
549-
SYS_IND(p) == MINIX_PARTITION) { /* subpartition table present */
547+
p->sys_ind == MINIX_PARTITION) { /* subpartition table present */
550548
char tmp[1 + BDEVNAME_SIZE + 10 + 9 + 1];
551549

552550
snprintf(tmp, sizeof(tmp), " %s%d: <minix:", state->name, origin);
@@ -555,7 +553,7 @@ static void parse_minix(struct parsed_partitions *state,
555553
if (state->next == state->limit)
556554
break;
557555
/* add each partition in use */
558-
if (SYS_IND(p) == MINIX_PARTITION)
556+
if (p->sys_ind == MINIX_PARTITION)
559557
put_partition(state, state->next++,
560558
start_sect(p), nr_sects(p));
561559
}
@@ -643,7 +641,7 @@ int msdos_partition(struct parsed_partitions *state)
643641
p = (struct msdos_partition *) (data + 0x1be);
644642
for (slot = 1 ; slot <= 4 ; slot++, p++) {
645643
/* If this is an EFI GPT disk, msdos should ignore it. */
646-
if (SYS_IND(p) == EFI_PMBR_OSTYPE_EFI_GPT) {
644+
if (p->sys_ind == EFI_PMBR_OSTYPE_EFI_GPT) {
647645
put_dev_sector(sect);
648646
return 0;
649647
}
@@ -685,11 +683,11 @@ int msdos_partition(struct parsed_partitions *state)
685683
}
686684
put_partition(state, slot, start, size);
687685
set_info(state, slot, disksig);
688-
if (SYS_IND(p) == LINUX_RAID_PARTITION)
686+
if (p->sys_ind == LINUX_RAID_PARTITION)
689687
state->parts[slot].flags = ADDPART_FLAG_RAID;
690-
if (SYS_IND(p) == DM6_PARTITION)
688+
if (p->sys_ind == DM6_PARTITION)
691689
strlcat(state->pp_buf, "[DM]", PAGE_SIZE);
692-
if (SYS_IND(p) == EZD_PARTITION)
690+
if (p->sys_ind == EZD_PARTITION)
693691
strlcat(state->pp_buf, "[EZD]", PAGE_SIZE);
694692
}
695693

@@ -698,7 +696,7 @@ int msdos_partition(struct parsed_partitions *state)
698696
/* second pass - output for each on a separate line */
699697
p = (struct msdos_partition *) (0x1be + data);
700698
for (slot = 1 ; slot <= 4 ; slot++, p++) {
701-
unsigned char id = SYS_IND(p);
699+
unsigned char id = p->sys_ind;
702700
int n;
703701

704702
if (!nr_sects(p))

0 commit comments

Comments
 (0)