diff mbox series

time: Fix strftime(3) API regarding nullability

Message ID 20230312000810.51652-1-alx@kernel.org
State New
Headers show
Series time: Fix strftime(3) API regarding nullability | expand

Commit Message

Alejandro Colomar March 12, 2023, 12:08 a.m. UTC
strftime(3) doesn't accept null pointers in any of the parameters.

Cc: Paul Eggert <eggert@cs.ucla.edu>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 time/time.h | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

Comments

Adhemerval Zanella Netto March 13, 2023, 5:10 p.m. UTC | #1
On 11/03/23 21:08, Alejandro Colomar via Libc-alpha wrote:
> strftime(3) doesn't accept null pointers in any of the parameters.
> 
> Cc: Paul Eggert <eggert@cs.ucla.edu>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  time/time.h | 3 ++-
>  1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/time/time.h b/time/time.h
> index d18089116e..28fb075b19 100644
> --- a/time/time.h
> +++ b/time/time.h
> @@ -99,7 +99,8 @@ extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
>     of characters written, or 0 if it would exceed MAXSIZE.  */
>  extern size_t strftime (char *__restrict __s, size_t __maxsize,
>  			const char *__restrict __format,
> -			const struct tm *__restrict __tp) __THROW;
> +			const struct tm *__restrict __tp)
> +			__THROW __nonnull((1, 3, 4));
>  
>  #ifdef __USE_XOPEN
>  /* Parse S according to FORMAT and store binary time information in TP.
Alejandro Colomar March 30, 2023, 11:43 p.m. UTC | #2
Ping :)

On 3/13/23 18:10, Adhemerval Zanella Netto wrote:
> 
> 
> On 11/03/23 21:08, Alejandro Colomar via Libc-alpha wrote:
>> strftime(3) doesn't accept null pointers in any of the parameters.
>>
>> Cc: Paul Eggert <eggert@cs.ucla.edu>
>> Signed-off-by: Alejandro Colomar <alx@kernel.org>
> 
> LGTM, thanks.
> 
> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
> 
>> ---
>>  time/time.h | 3 ++-
>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>
>> diff --git a/time/time.h b/time/time.h
>> index d18089116e..28fb075b19 100644
>> --- a/time/time.h
>> +++ b/time/time.h
>> @@ -99,7 +99,8 @@ extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
>>     of characters written, or 0 if it would exceed MAXSIZE.  */
>>  extern size_t strftime (char *__restrict __s, size_t __maxsize,
>>  			const char *__restrict __format,
>> -			const struct tm *__restrict __tp) __THROW;
>> +			const struct tm *__restrict __tp)
>> +			__THROW __nonnull((1, 3, 4));
>>  
>>  #ifdef __USE_XOPEN
>>  /* Parse S according to FORMAT and store binary time information in TP.
Adhemerval Zanella Netto March 31, 2023, 1:37 p.m. UTC | #3
Committed, thanks.

On 30/03/23 20:43, Alejandro Colomar wrote:
> Ping :)
> 
> On 3/13/23 18:10, Adhemerval Zanella Netto wrote:
>>
>>
>> On 11/03/23 21:08, Alejandro Colomar via Libc-alpha wrote:
>>> strftime(3) doesn't accept null pointers in any of the parameters.
>>>
>>> Cc: Paul Eggert <eggert@cs.ucla.edu>
>>> Signed-off-by: Alejandro Colomar <alx@kernel.org>
>>
>> LGTM, thanks.
>>
>> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>>
>>> ---
>>>  time/time.h | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/time/time.h b/time/time.h
>>> index d18089116e..28fb075b19 100644
>>> --- a/time/time.h
>>> +++ b/time/time.h
>>> @@ -99,7 +99,8 @@ extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
>>>     of characters written, or 0 if it would exceed MAXSIZE.  */
>>>  extern size_t strftime (char *__restrict __s, size_t __maxsize,
>>>  			const char *__restrict __format,
>>> -			const struct tm *__restrict __tp) __THROW;
>>> +			const struct tm *__restrict __tp)
>>> +			__THROW __nonnull((1, 3, 4));
>>>  
>>>  #ifdef __USE_XOPEN
>>>  /* Parse S according to FORMAT and store binary time information in TP.
>
Sam James March 31, 2023, 6:33 p.m. UTC | #4
Alejandro Colomar via Libc-alpha <libc-alpha@sourceware.org> writes:

> [[PGP Signed Part:Undecided]]
> Ping :)
>
> On 3/13/23 18:10, Adhemerval Zanella Netto wrote:
>> 
>> 
>> On 11/03/23 21:08, Alejandro Colomar via Libc-alpha wrote:
>>> strftime(3) doesn't accept null pointers in any of the parameters.
>>>
>>> Cc: Paul Eggert <eggert@cs.ucla.edu>
>>> Signed-off-by: Alejandro Colomar <alx@kernel.org>
>> 
>> LGTM, thanks.
>> 
>> Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
>> 
>>> ---
>>>  time/time.h | 3 ++-
>>>  1 file changed, 2 insertions(+), 1 deletion(-)
>>>
>>> diff --git a/time/time.h b/time/time.h
>>> index d18089116e..28fb075b19 100644
>>> --- a/time/time.h
>>> +++ b/time/time.h
>>> @@ -99,7 +99,8 @@ extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
>>>     of characters written, or 0 if it would exceed MAXSIZE.  */
>>>  extern size_t strftime (char *__restrict __s, size_t __maxsize,
>>>  			const char *__restrict __format,
>>> -			const struct tm *__restrict __tp) __THROW;
>>> +			const struct tm *__restrict __tp)
>>> +			__THROW __nonnull((1, 3, 4));
>>>  
>>>  #ifdef __USE_XOPEN
>>>  /* Parse S according to FORMAT and store binary time information in TP.

Nice spot. I suspect there's a few more of these we need to fix too.
diff mbox series

Patch

diff --git a/time/time.h b/time/time.h
index d18089116e..28fb075b19 100644
--- a/time/time.h
+++ b/time/time.h
@@ -99,7 +99,8 @@  extern time_t __REDIRECT_NTH (mktime, (struct tm *__tp), __mktime64);
    of characters written, or 0 if it would exceed MAXSIZE.  */
 extern size_t strftime (char *__restrict __s, size_t __maxsize,
 			const char *__restrict __format,
-			const struct tm *__restrict __tp) __THROW;
+			const struct tm *__restrict __tp)
+			__THROW __nonnull((1, 3, 4));
 
 #ifdef __USE_XOPEN
 /* Parse S according to FORMAT and store binary time information in TP.