NetBSD-Bugs archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: install/41117: ddb.onpanic=0 in default sysctl.conf(5) could cause error



On Apr 1,  3:15pm, martin%duskware.de@localhost (Martin Husemann) wrote:
-- Subject: Re: install/41117: ddb.onpanic=0 in default sysctl.conf(5) could 

| The following reply was made to PR install/41117; it has been noted by GNATS.
| 
| From: Martin Husemann <martin%duskware.de@localhost>
| To: gnats-bugs%NetBSD.org@localhost
| Cc: 
| Subject: Re: install/41117: ddb.onpanic=0 in default sysctl.conf(5) could 
cause error
| Date: Wed, 1 Apr 2009 17:13:39 +0200
| 
|  On Wed, Apr 01, 2009 at 03:10:07PM +0000, Christos Zoulas wrote:
|  >    req = 1;
|  >    key = l;
|  >  + if ((value = strchr(l, '?')) != NULL) {
|  >  +         *value = '\0';
|  >  +         optional = true;
|  >  + }
|  >    value = strchr(l, '=');
|  
|  How about:
|  
|       if ((value = strstr(l, "?=")) != NULL) {
|               *value = '\0';
|               optional = true;
|       } else {
|               value = strchr(l, '=');
|       }

much better, but I would do:

        if ((value = strstr(l, "?=")) != NULL) {
                *value++ = '\0';
                optional = true;
        } else {
                value = strchr(l, '=');
        }

to leave value on top of the '='... Or to avoid 2 scans:

        if ((value = strchr(l, '=')) != NULL) {
                if (value > l && value[-1] == '?') {
                        value[-1] = '\0';
                        optional = true;
                }
                ....

christos


Home | Main Index | Thread Index | Old Index