[prev in list] [next in list] [prev in thread] [next in thread]
List: busybox
Subject: Re: [PATCH] deluser patch 02
From: Tito <farmatito () tiscali ! it>
Date: 2006-11-30 7:47:23
Message-ID: 200611300847.23362.farmatito () tiscali ! it
[Download RAW message or body]
On Thursday 30 November 2006 00:49, Denis Vlasenko wrote:
> On Wednesday 29 November 2006 20:50, Tito wrote:
> > Hi Denis,
> > This patch modifies the ENABLE_FEATURE_CLEAN_UP stuff in deluser so that it is not
> > necessary to duplicate the code and adds ENABLE_FEATURE_CLEAN_UP in a few
> > more places to be coherent thus saving some size.
> > Please take a look at it and apply it if
> > you like it.
>
> After trying several ways to write it, i decided to code
> ENABLE_FEATURE_CLEAN_UP and !ENABLE_FEATURE_CLEAN_UP versions
> completely separated. Only one is compiled into binary anyway,
> so there is no risk of code duplication.
>
> But it is _much_ easier to review.
>
> Current svn:
>
> ...
> if (!ENABLE_FEATURE_CLEAN_UP) {
> if (!found) {
> bb_error_msg("can't find '%s' in '%s'", login, filename);
> return;
> }
> passwd = fopen_or_warn(filename, "w");
> if (passwd)
> while ((line = llist_pop(&plist)))
> fputs(line, passwd);
> } else {
> if (!found) {
> bb_error_msg("can't find '%s' in '%s'", login, filename);
> goto clean_up;
> }
> fclose(passwd);
> passwd = fopen_or_warn(filename, "w");
> if (passwd) {
> clean_up:
> while ((line = llist_pop(&plist))) {
> if (found) fputs(line, passwd);
> free(line);
> }
> fclose(passwd);
> }
> }
> }
>
> Is it good enough? Entire file is attached.
Looks good to me if you prefer it this way. Just for coherence:
while ((line = xmalloc_fgets(passwd))) {
if (!strncmp(line, login, len)
&& line[len] == ':'
) {
found++;
- free(line);
+ if (ENABLE__FEATURE_CLEAN_UP) free (line);
} else {
llist_add_to_end(&plist, line);
}
}
Ciao,
Tito
> --
> vda
>
_______________________________________________
busybox mailing list
busybox@busybox.net
http://busybox.net/cgi-bin/mailman/listinfo/busybox
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic