>>> Robert Story <rst...@freesnmp.com> schrieb am 08.11.2016 um 21:17 in 
>>> Nachricht
<20161108151723.282ff...@ispx.vb.futz.org>:

[...]
> So the strlen - 1 chops off the newline.

Actually it tries to remove the last character before '\0', even if there is 
none. For safetly there should be a check for a zero-length string, because 
otherwise bad things may happen.

I'd prefer

char *cp;
for (cp = tmpuf2; *cp != '\0'; ++cp)
        if (*cp == '\n') {
                *cp = '\0';
                break;
        }
}
because it does what you say, and nothing else.

Ulrich




------------------------------------------------------------------------------
Developer Access Program for Intel Xeon Phi Processors
Access to Intel Xeon Phi processor-based developer platforms.
With one year of Intel Parallel Studio XE.
Training and support from Colfax.
Order your platform today. http://sdm.link/xeonphi
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to