[SSSD] [PATCH] DB: Switch to new libini_config API
Dmitri Pal
dpal at redhat.com
Mon Apr 22 16:23:20 UTC 2013
On 04/22/2013 10:09 AM, Ondrej Kos wrote:
>>
>>> if (ret <= 0 || ret >= 21) {
>>
>> you can use sizeof(timestr) here in the odd case timestr actually
>> changed.
>
> quoting the reference:
> Return Value
> The number of characters that would have been written if n had been
> sufficiently large, not counting the terminating null character.
> If an encoding error occurs, a negative number is returned.
> Notice that only when this returned value is non-negative and less
> than n, the string has been completely written.
> (where N is the sizeof parameter)
>
> so I'd rather leave it this way, seems more defensive
I am not sure it is more defensive.
If you do not want to to use sizeof I am fine but I would at least use:
#define TIME_STRING_SIZE 21
...
char timebuf[TIME_STRING_SIZE];
...
if (ret <= 0 || ret >= TIME_STRING_SIZE) {
...
Seems more defensive to me that literally "21".
--
Thank you,
Dmitri Pal
Sr. Engineering Manager for IdM portfolio
Red Hat Inc.
-------------------------------
Looking to carve out IT costs?
www.redhat.com/carveoutcosts/
More information about the sssd-devel
mailing list