Hi Tito,
On Wed, Oct 20, 2010 at 05:03:38PM +0200, Tito wrote:
[snip]
> just for fun a different approach to the add/remove shell problem.
> This is really small. Bloat-o-meter says:
>
> debian:~/Desktop/test/busybox$ scripts/bloat-o-meter busybox_old
> busybox_unstripped
> function old new delta
> update_passwd 1273 1335 +62
> dont_add 2 - -2
> .rodata 135419 135406 -13
> add_remove_shell_main 259 62 -197
> ------------------------------------------------------------------------------
> (add/remove: 0/1 grow/shrink: 1/2 up/down: 62/-212) Total: -150 bytes
>
> It is a little tested and seems to work fine for me.
> It also adds argc check and usage message.
> Hints and critics on how to shrink it even more are welcome!
[snip]
> @@ -167,6 +177,18 @@
> line = xmalloc_fgetline(old_fp);
> if (!line) /* EOF/error */
> break;
> +#if ENABLE_ADD_SHELL || ENABLE_REMOVE_SHELL
This #if seems redundant to me, and it makes the code less readable. The
compiler should optimize this code section away when the (ADD_SHELL ||
REMOVE_SHELL) expression is 0 at compile time.
baruch
> + if (ADD_SHELL || REMOVE_SHELL) {
> + /* remove colon */
> + name_colon[user_len - 1] = '\0';
> + if (strcmp(name_colon, line) != 0) {
> + fprintf(new_fp, "%s\n", line);
> + goto next;
> + } else if (REMOVE_SHELL) {
> + changed_lines++;
> + }
> + } else
> +#endif
--
~. .~ Tk Open Systems
=}------------------------------------------------ooO--U--Ooo------------{=
- [email protected] - tel: +972.2.679.5364, http://www.tkos.co.il -
_______________________________________________
busybox mailing list
[email protected]
http://lists.busybox.net/mailman/listinfo/busybox