Skip to contentSkip to conversation

erofs-utils: lib: rearrange struct erofs_configure

PATCH Superseded Hongzhen Luo 2 participants 2 messages Nov 11, 2024

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 erofs-utils: lib: rearrange struct erofs_configure

Move the content defined by the NDEBUG macro to the end. The reason for doing this is to maintain a consistent layout for all preceding variables when a third-party application defines NDEBUG while erofs-utils does not (by default).

Fixes ad6c80dc168d ("erofs-utils: lib: add erofs_get_configure()")
---
 include/erofs/config.h | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
include/erofs/config.h +4 -4
index ae366c150232..cff4ceadb7bc 100644
@@ -46,10 +46,6 @@ struct erofs_configure {
 	int c_dbg_lvl;
 	bool c_dry_run;
 	bool c_legacy_compress;
-#ifndef NDEBUG
-	bool c_random_pclusterblks;
-	bool c_random_algorithms;
-#endif
 	char c_timeinherit;
 	char c_chunkbits;
 	bool c_inline_data;
@@ -94,6 +90,10 @@ struct erofs_configure {
 	char *fs_config_file;
 	char *block_list_file;
 #endif
+#ifndef NDEBUG
+	bool c_random_pclusterblks;
+	bool c_random_algorithms;
+#endif
 };
 
 extern struct erofs_configure cfg;
Signature · 1 line
2.43.5
#1 lore raw
Quoted 1 line · Hongzhen Luo

Move the content defined by the NDEBUG macro to the end.

Move the fields controlled by the NDEBUG macro to the end to maintain a consistent layout for preceding variables.

It addresses cases where a third-party application defines NDEBUG while erofs-utils does not (by default). Ideally, third-party applications should use the same macros as erofs-utils to get a unique struct erofs_configure. However, since NDEBUG enables unnecessary assertions, restructuring the layout resolves such inconsistencies.

Quoted 39 lines

The reason for doing this is to maintain a consistent layout for all preceding variables when a third-party application defines NDEBUG while erofs-utils does not (by default).

Fixes ad6c80dc168d ("erofs-utils: lib: add erofs_get_configure()")
---
  include/erofs/config.h | 8 ++++----
  1 file changed, 4 insertions(+), 4 deletions(-)
include/erofs/config.h +4 -4
index ae366c150232..cff4ceadb7bc 100644
@@ -46,10 +46,6 @@ struct erofs_configure {
  	int c_dbg_lvl;
  	bool c_dry_run;
  	bool c_legacy_compress;
-#ifndef NDEBUG
-	bool c_random_pclusterblks;
-	bool c_random_algorithms;
-#endif
  	char c_timeinherit;
  	char c_chunkbits;
  	bool c_inline_data;
@@ -94,6 +90,10 @@ struct erofs_configure {
  	char *fs_config_file;
  	char *block_list_file;
  #endif
+#ifndef NDEBUG
+	bool c_random_pclusterblks;
+	bool c_random_algorithms;
+#endif
  };
 
  extern struct erofs_configure cfg;