diff options
author | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-04 10:16:52 +0000 |
---|---|---|
committer | Denis Vlasenko <vda.linux@googlemail.com> | 2007-06-04 10:16:52 +0000 |
commit | 74324c86663f57a19c1de303ee8c8e5449db9ef2 (patch) | |
tree | 11f5da9de4212875ce5811be2e1050e076378c9a /editors/sed.c | |
parent | 4e5f82c76f08614d0b69f9ec4a8baac303af15f6 (diff) | |
download | busybox-w32-74324c86663f57a19c1de303ee8c8e5449db9ef2.tar.gz busybox-w32-74324c86663f57a19c1de303ee8c8e5449db9ef2.tar.bz2 busybox-w32-74324c86663f57a19c1de303ee8c8e5449db9ef2.zip |
Audit bb_common_bufsiz usage, add script which looks for misuse.
tr: stop using globals needlessly.
code: -103 bytes
Diffstat (limited to 'editors/sed.c')
-rw-r--r-- | editors/sed.c | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/editors/sed.c b/editors/sed.c index d49627ff4..d0c2ca742 100644 --- a/editors/sed.c +++ b/editors/sed.c | |||
@@ -118,8 +118,14 @@ struct globals { | |||
118 | int len; /* Space allocated */ | 118 | int len; /* Space allocated */ |
119 | } pipeline; | 119 | } pipeline; |
120 | }; | 120 | }; |
121 | |||
122 | #define G (*(struct globals*)&bb_common_bufsiz1) | 121 | #define G (*(struct globals*)&bb_common_bufsiz1) |
122 | void BUG_sed_globals_too_big(void); | ||
123 | #define INIT_G() do { \ | ||
124 | if (sizeof(struct globals) > COMMON_BUFSIZE) \ | ||
125 | BUG_sed_globals_too_big(); \ | ||
126 | G.sed_cmd_tail = &G.sed_cmd_head; \ | ||
127 | } while (0) | ||
128 | |||
123 | 129 | ||
124 | #if ENABLE_FEATURE_CLEAN_UP | 130 | #if ENABLE_FEATURE_CLEAN_UP |
125 | static void sed_free_and_close_stuff(void) | 131 | static void sed_free_and_close_stuff(void) |
@@ -1210,8 +1216,6 @@ static void add_cmd_block(char *cmdstr) | |||
1210 | free(sv); | 1216 | free(sv); |
1211 | } | 1217 | } |
1212 | 1218 | ||
1213 | void BUG_sed_globals_too_big(void); | ||
1214 | |||
1215 | int sed_main(int argc, char **argv); | 1219 | int sed_main(int argc, char **argv); |
1216 | int sed_main(int argc, char **argv) | 1220 | int sed_main(int argc, char **argv) |
1217 | { | 1221 | { |
@@ -1222,10 +1226,7 @@ int sed_main(int argc, char **argv) | |||
1222 | llist_t *opt_e, *opt_f; | 1226 | llist_t *opt_e, *opt_f; |
1223 | int status = EXIT_SUCCESS; | 1227 | int status = EXIT_SUCCESS; |
1224 | 1228 | ||
1225 | if (sizeof(struct globals) > sizeof(bb_common_bufsiz1)) | 1229 | INIT_G(); |
1226 | BUG_sed_globals_too_big(); | ||
1227 | |||
1228 | G.sed_cmd_tail = &G.sed_cmd_head; | ||
1229 | 1230 | ||
1230 | /* destroy command strings on exit */ | 1231 | /* destroy command strings on exit */ |
1231 | if (ENABLE_FEATURE_CLEAN_UP) atexit(sed_free_and_close_stuff); | 1232 | if (ENABLE_FEATURE_CLEAN_UP) atexit(sed_free_and_close_stuff); |