Michael Hunter wrote: >> Webrev is at: >> >> http://zhadum.east/export/ws/am223141/checkout-area/nwam1-fixes/webrev/ >> > nwamcfg.c:1247-1254 better as 'while(end >= 0 && (str[end] == '"' || > str[end] == '\n')) end--; str[end+1] = 0;' instead of trying to > enumerate various combos? > > nwamcfg.c:3935 should be putchar() > > nwamcfg.h:42 max length of "" to me would be 1 since the string > contains an implied 0 termination > Thanks Michael. All comments accepted. Diffs below:
diff -r 2adbb065f174 usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c --- a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c Mon Aug 31 16:36:38 2009 -0400 +++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.c Wed Sep 02 09:12:17 2009 -0400 @@ -1230,7 +1230,7 @@ trim_quotes(const char *quoted_str) { char *str; - int len; + int end; /* export_func() and list_func() can pass NULL here */ if (quoted_str == NULL) @@ -1245,13 +1245,10 @@ return (NULL); /* remove trailing quote and newline */ - len = strlen(str); - if (str[len - 1] == '\n') { - str[len - 1] = '\0'; - if (str[len - 2] == '"') - str[len - 2] = '\0'; - } else if (str[len - 1] == '"') - str[len - 1] = '\0'; + end = strlen(str) - 1; + while (end >= 0 && (str[end] == '"' || str[end] == '\n')) + end--; + str[end+1] = 0; return (str); } @@ -3811,7 +3808,7 @@ choices = B_TRUE; } if (choices) - (void) printf("]"); + (void) putchar(']'); break; case NWAM_VALUE_TYPE_BOOLEAN: (void) printf(" [%s|%s]", "true", "false"); @@ -3932,7 +3929,7 @@ if (ret == NWAM_SUCCESS) { (void) printf(" ("); output_prop_val(props[i], vals, stdout, B_TRUE); - (void) printf(")"); + (void) putchar(')'); nwam_value_free(vals); } /* print choices, won't print anything if there aren't any */ diff -r 2adbb065f174 usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.h --- a/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.h Mon Aug 31 16:36:38 2009 -0400 +++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamcfg/nwamcfg.h Wed Sep 02 09:12:17 2009 -0400 @@ -40,7 +40,7 @@ #define NWAM_REPEAT 2 /* max length of "ncu", "ncp", "loc", "enm", "wlan" */ -#define NWAM_MAX_TYPE_LEN 4 +#define NWAM_MAX_TYPE_LEN 5 #define CMD_CANCEL 0 #define CMD_CLEAR 1 am223141 at zhadum:nwam1-fixes$