networking/interface.c: tiny code shrink

function                                             old     new   delta
if_readlist_proc                                     634     631      -3

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-10-22 19:42:26 +02:00
parent f125b6d341
commit 6935ec9c0b
2 changed files with 12 additions and 12 deletions

View File

@ -359,7 +359,8 @@ static int parse_subst_cmd(sed_cmd_t *sed_cmd, const char *substr)
continue; continue;
} }
/* Skip spaces */ /* Skip spaces */
if (isspace(substr[idx])) continue; if (isspace(substr[idx]))
continue;
switch (substr[idx]) { switch (substr[idx]) {
/* Replace all occurrences */ /* Replace all occurrences */
@ -417,8 +418,7 @@ static const char *parse_cmd_args(sed_cmd_t *sed_cmd, const char *cmdstr)
/* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */ /* handle edit cmds: (a)ppend, (i)nsert, and (c)hange */
else if (strchr("aic", sed_cmd->cmd)) { else if (strchr("aic", sed_cmd->cmd)) {
if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd != 'c') if ((sed_cmd->end_line || sed_cmd->end_match) && sed_cmd->cmd != 'c')
bb_error_msg_and_die bb_error_msg_and_die("only a beginning address can be specified for edit commands");
("only a beginning address can be specified for edit commands");
for (;;) { for (;;) {
if (*cmdstr == '\n' || *cmdstr == '\\') { if (*cmdstr == '\n' || *cmdstr == '\\') {
cmdstr++; cmdstr++;

View File

@ -410,20 +410,20 @@ static struct interface *add_interface(char *name)
static char *get_name(char *name, char *p) static char *get_name(char *name, char *p)
{ {
/* Extract <name> from nul-terminated p where p matches /* Extract <name> from nul-terminated p where p matches
<name>: after leading whitespace. * <name>: after leading whitespace.
If match is not made, set name empty and return unchanged p */ * If match is not made, set name empty and return unchanged p
int namestart = 0, nameend = 0; */
char *nameend;
char *namestart = skip_whitespace(p);
while (isspace(p[namestart]))
namestart++;
nameend = namestart; nameend = namestart;
while (p[nameend] && p[nameend] != ':' && !isspace(p[nameend])) while (*nameend && *nameend != ':' && !isspace(*nameend))
nameend++; nameend++;
if (p[nameend] == ':') { if (*nameend == ':') {
if ((nameend - namestart) < IFNAMSIZ) { if ((nameend - namestart) < IFNAMSIZ) {
memcpy(name, &p[namestart], nameend - namestart); memcpy(name, namestart, nameend - namestart);
name[nameend - namestart] = '\0'; name[nameend - namestart] = '\0';
p = &p[nameend]; p = nameend;
} else { } else {
/* Interface name too large */ /* Interface name too large */
name[0] = '\0'; name[0] = '\0';