Skip to contentSkip to conversation

udf: Fix meaning of ENTITYID_FLAGS_* macros to be really bitwise-or flags

PATCH In review Pali Rohár 2 participants 2 messages Jan 12, 2020 – Jan 13, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 udf: Fix meaning of ENTITYID_FLAGS_* macros to be really bitwise-or flags

Currently ENTITYID_FLAGS_* macros definitions are written as hex numbers but their meaning is not bitwise-or flags. But rather bit position. This is unusual and could be misleading. So change meaning of ENTITYID_FLAGS_* macros definitions to be really bitwise-or flags.

---
 fs/udf/ecma_167.h | 4 ++--
 fs/udf/super.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/udf/ecma_167.h +2 -2
index f9ee412fe..3fd85464a 100644
@@ -95,8 +95,8 @@ struct regid {
 } __packed;
 
 /* Flags (ECMA 167r3 1/7.4.1) */
-#define ENTITYID_FLAGS_DIRTY		0x00
-#define ENTITYID_FLAGS_PROTECTED	0x01
+#define ENTITYID_FLAGS_DIRTY		0x01
+#define ENTITYID_FLAGS_PROTECTED	0x02
 
 /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
 #define VSD_STD_ID_LEN			5
fs/udf/super.c +1 -1
index 0dad63f88..7e6ec9fa0 100644
@@ -773,7 +773,7 @@ static int udf_verify_domain_identifier(struct super_block *sb,
 		udf_warn(sb, "Not OSTA UDF compliant %s descriptor.\n", dname);
 		goto force_ro;
 	}
-	if (ident->flags & (1 << ENTITYID_FLAGS_DIRTY)) {
+	if (ident->flags & ENTITYID_FLAGS_DIRTY) {
 		udf_warn(sb, "Possibly not OSTA UDF compliant %s descriptor.\n",
 			 dname);
 		goto force_ro;
Signature · 1 line
2.20.1
reviewer
#1 lore raw
Quoted 6 lines · Pali Rohár

Currently ENTITYID_FLAGS_* macros definitions are written as hex numbers but their meaning is not bitwise-or flags. But rather bit position. This is unusual and could be misleading. So change meaning of ENTITYID_FLAGS_* macros definitions to be really bitwise-or flags.

Thanks. I agree. I've added this patch to my tree.

Honza

Quoted 36 lines
---
 fs/udf/ecma_167.h | 4 ++--
 fs/udf/super.c    | 2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)
fs/udf/ecma_167.h +2 -2
index f9ee412fe..3fd85464a 100644
@@ -95,8 +95,8 @@ struct regid {
 } __packed;
 
 /* Flags (ECMA 167r3 1/7.4.1) */
-#define ENTITYID_FLAGS_DIRTY		0x00
-#define ENTITYID_FLAGS_PROTECTED	0x01
+#define ENTITYID_FLAGS_DIRTY		0x01
+#define ENTITYID_FLAGS_PROTECTED	0x02
 
 /* Volume Structure Descriptor (ECMA 167r3 2/9.1) */
 #define VSD_STD_ID_LEN			5
fs/udf/super.c +1 -1
index 0dad63f88..7e6ec9fa0 100644
@@ -773,7 +773,7 @@ static int udf_verify_domain_identifier(struct super_block *sb,
 		udf_warn(sb, "Not OSTA UDF compliant %s descriptor.\n", dname);
 		goto force_ro;
 	}
-	if (ident->flags & (1 << ENTITYID_FLAGS_DIRTY)) {
+	if (ident->flags & ENTITYID_FLAGS_DIRTY) {
 		udf_warn(sb, "Possibly not OSTA UDF compliant %s descriptor.\n",
 			 dname);
 		goto force_ro;
Signature · 1 line
2.20.1
Signature · 2 lines
Jan Kara <[email protected]>
SUSE Labs, CR