diff options
-rw-r--r-- | e2fsprogs/tune2fs.c | 17 | ||||
-rw-r--r-- | include/libbb.h | 17 | ||||
-rw-r--r-- | util-linux/mkfs_ext2.c | 17 | ||||
-rw-r--r-- | util-linux/mkfs_reiser.c | 16 | ||||
-rw-r--r-- | util-linux/mkfs_vfat.c | 13 |
5 files changed, 17 insertions, 63 deletions
diff --git a/e2fsprogs/tune2fs.c b/e2fsprogs/tune2fs.c index a1caf011c..f7fcd88bf 100644 --- a/e2fsprogs/tune2fs.c +++ b/e2fsprogs/tune2fs.c | |||
@@ -39,23 +39,6 @@ | |||
39 | #include <linux/fs.h> | 39 | #include <linux/fs.h> |
40 | #include "bb_e2fs_defs.h" | 40 | #include "bb_e2fs_defs.h" |
41 | 41 | ||
42 | // storage helpers | ||
43 | char BUG_wrong_field_size(void); | ||
44 | #define STORE_LE(field, value) \ | ||
45 | do { \ | ||
46 | if (sizeof(field) == 4) \ | ||
47 | field = SWAP_LE32(value); \ | ||
48 | else if (sizeof(field) == 2) \ | ||
49 | field = SWAP_LE16(value); \ | ||
50 | else if (sizeof(field) == 1) \ | ||
51 | field = (value); \ | ||
52 | else \ | ||
53 | BUG_wrong_field_size(); \ | ||
54 | } while (0) | ||
55 | |||
56 | #define FETCH_LE32(field) \ | ||
57 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | ||
58 | |||
59 | enum { | 42 | enum { |
60 | OPT_L = 1 << 0, // label | 43 | OPT_L = 1 << 0, // label |
61 | OPT_c = 1 << 1, // max mount count | 44 | OPT_c = 1 << 1, // max mount count |
diff --git a/include/libbb.h b/include/libbb.h index 7cad12c44..61fa1e03e 100644 --- a/include/libbb.h +++ b/include/libbb.h | |||
@@ -2127,6 +2127,23 @@ extern const char bb_default_login_shell[] ALIGN1; | |||
2127 | # define FB_0 "/dev/fb0" | 2127 | # define FB_0 "/dev/fb0" |
2128 | #endif | 2128 | #endif |
2129 | 2129 | ||
2130 | // storage helpers for mk*fs utilities | ||
2131 | char BUG_wrong_field_size(void); | ||
2132 | #define STORE_LE(field, value) \ | ||
2133 | do { \ | ||
2134 | if (sizeof(field) == 4) \ | ||
2135 | field = SWAP_LE32((uint32_t)(value)); \ | ||
2136 | else if (sizeof(field) == 2) \ | ||
2137 | field = SWAP_LE16((uint16_t)(value)); \ | ||
2138 | else if (sizeof(field) == 1) \ | ||
2139 | field = (uint8_t)(value); \ | ||
2140 | else \ | ||
2141 | BUG_wrong_field_size(); \ | ||
2142 | } while (0) | ||
2143 | |||
2144 | #define FETCH_LE32(field) \ | ||
2145 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | ||
2146 | |||
2130 | 2147 | ||
2131 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) | 2148 | #define ARRAY_SIZE(x) ((unsigned)(sizeof(x) / sizeof((x)[0]))) |
2132 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) | 2149 | #define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) |
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index f524bc239..bda168f1e 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c | |||
@@ -78,23 +78,6 @@ | |||
78 | #define EXT2_FLAGS_SIGNED_HASH 0x0001 | 78 | #define EXT2_FLAGS_SIGNED_HASH 0x0001 |
79 | #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 | 79 | #define EXT2_FLAGS_UNSIGNED_HASH 0x0002 |
80 | 80 | ||
81 | // storage helpers | ||
82 | char BUG_wrong_field_size(void); | ||
83 | #define STORE_LE(field, value) \ | ||
84 | do { \ | ||
85 | if (sizeof(field) == 4) \ | ||
86 | field = SWAP_LE32((uint32_t)(value)); \ | ||
87 | else if (sizeof(field) == 2) \ | ||
88 | field = SWAP_LE16((uint16_t)(value)); \ | ||
89 | else if (sizeof(field) == 1) \ | ||
90 | field = (uint8_t)(value); \ | ||
91 | else \ | ||
92 | BUG_wrong_field_size(); \ | ||
93 | } while (0) | ||
94 | |||
95 | #define FETCH_LE32(field) \ | ||
96 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | ||
97 | |||
98 | // All fields are little-endian | 81 | // All fields are little-endian |
99 | struct ext2_dir { | 82 | struct ext2_dir { |
100 | uint32_t inode1; | 83 | uint32_t inode1; |
diff --git a/util-linux/mkfs_reiser.c b/util-linux/mkfs_reiser.c index 390aef86c..b4c8dda6f 100644 --- a/util-linux/mkfs_reiser.c +++ b/util-linux/mkfs_reiser.c | |||
@@ -28,22 +28,6 @@ | |||
28 | #include "libbb.h" | 28 | #include "libbb.h" |
29 | #include <linux/fs.h> | 29 | #include <linux/fs.h> |
30 | 30 | ||
31 | char BUG_wrong_field_size(void); | ||
32 | #define STORE_LE(field, value) \ | ||
33 | do { \ | ||
34 | if (sizeof(field) == 4) \ | ||
35 | field = SWAP_LE32(value); \ | ||
36 | else if (sizeof(field) == 2) \ | ||
37 | field = SWAP_LE16(value); \ | ||
38 | else if (sizeof(field) == 1) \ | ||
39 | field = (value); \ | ||
40 | else \ | ||
41 | BUG_wrong_field_size(); \ | ||
42 | } while (0) | ||
43 | |||
44 | #define FETCH_LE32(field) \ | ||
45 | (sizeof(field) == 4 ? SWAP_LE32(field) : BUG_wrong_field_size()) | ||
46 | |||
47 | struct journal_params { | 31 | struct journal_params { |
48 | uint32_t jp_journal_1st_block; /* where does journal start from on its device */ | 32 | uint32_t jp_journal_1st_block; /* where does journal start from on its device */ |
49 | uint32_t jp_journal_dev; /* journal device st_rdev */ | 33 | uint32_t jp_journal_dev; /* journal device st_rdev */ |
diff --git a/util-linux/mkfs_vfat.c b/util-linux/mkfs_vfat.c index 92f0e3b1a..6a6dc652f 100644 --- a/util-linux/mkfs_vfat.c +++ b/util-linux/mkfs_vfat.c | |||
@@ -206,19 +206,6 @@ static const char boot_code[] ALIGN1 = | |||
206 | #define MARK_CLUSTER(cluster, value) \ | 206 | #define MARK_CLUSTER(cluster, value) \ |
207 | ((uint32_t *)fat)[cluster] = SWAP_LE32(value) | 207 | ((uint32_t *)fat)[cluster] = SWAP_LE32(value) |
208 | 208 | ||
209 | void BUG_unsupported_field_size(void); | ||
210 | #define STORE_LE(field, value) \ | ||
211 | do { \ | ||
212 | if (sizeof(field) == 4) \ | ||
213 | field = SWAP_LE32((uint32_t)(value)); \ | ||
214 | else if (sizeof(field) == 2) \ | ||
215 | field = SWAP_LE16((uint16_t)(value)); \ | ||
216 | else if (sizeof(field) == 1) \ | ||
217 | field = (uint8_t)(value); \ | ||
218 | else \ | ||
219 | BUG_unsupported_field_size(); \ | ||
220 | } while (0) | ||
221 | |||
222 | /* compat: | 209 | /* compat: |
223 | * mkdosfs 2.11 (12 Mar 2005) | 210 | * mkdosfs 2.11 (12 Mar 2005) |
224 | * Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] | 211 | * Usage: mkdosfs [-A] [-c] [-C] [-v] [-I] [-l bad-block-file] |