Charles Lepple
2007-Aug-11 01:39 UTC
[Nut-upsdev] [nut-commits] svn commit r1040 - in trunk: . data drivers man
On 8/10/07, Arjen de Korte <adkorte-guest at alioth.debian.org> wrote:> Author: adkorte-guest > Date: Fri Aug 10 19:16:48 2007 > New Revision: 1040 > > Log: > From the ChangeLog:[...]> - Use snprintf instead of sprintf where possible.In general, this is a good idea, but what if the resulting string is exactly sizeof(buf) ? Shouldn't it be sizeof()-1 with a terminating NUL character at the end? -- - Charles Lepple
Arjen de Korte
2007-Aug-11 06:32 UTC
[Nut-upsdev] [nut-commits] svn commit r1040 - in trunk: . data drivers man
> On 8/10/07, Arjen de Korte <adkorte-guest at alioth.debian.org> wrote: >> Author: adkorte-guest >> Date: Fri Aug 10 19:16:48 2007 >> New Revision: 1040 >> >> Log: >> From the ChangeLog: > [...] >> - Use snprintf instead of sprintf where possible. > > In general, this is a good idea, but what if the resulting string is > exactly sizeof(buf) ? Shouldn't it be sizeof()-1 with a terminating > NUL character at the end?No, snprintf() deals with that already all by itself. If sizeof(buf) equals 'n', it will write up to n-1 characters and close with a '\0'. Best regards, Arjen -- Eindhoven - The Netherlands Key fingerprint - 66 4E 03 2C 9D B5 CB 9B 7A FE 7E C1 EE 88 BC 57
Seemingly Similar Threads
- [nut-commits] svn commit r1866 - in trunk: . drivers man
- [nut-commits] svn commit r1560 - trunk
- [nut-commits] svn commit r2777 - in trunk: data docs/man drivers scripts/hal scripts/hotplug scripts/udev
- [nut-commits] svn commit r2260 - trunk/drivers
- [nut-commits] svn commit r1728 - trunk/tools