[Top][All Lists]

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

Re: [PATCH] base32, base64: prefer signed to unsigned integers

From: Simon Josefsson
Subject: Re: [PATCH] base32, base64: prefer signed to unsigned integers
Date: Mon, 30 Aug 2021 16:12:20 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux)

Bruno Haible <bruno@clisp.org> writes:

> Hi Simon,
>> I'm not sure I understand why idx_t is better than size_t
>> here, can you elaborate?  Why not ssize_t?
> You find a detailed explanation in the comments of idx.h.

Thanks for the pointer -- it doesn't say anything about why ssize_t
can't be used though?  As a signed variant of size_t, it seems relevant
to consider.

>> Maybe a compromise is to
>> keep the old API but add new APIs with idx_t types and the
>> implementation of the old functions uses the new one.
> The objective is to eliminate bugs due to the use of unsigned types
> for numerical values.

Is that a realistic goal with C using the unsigned type size_t for
low-level functions like strlen()?  It seems like an un-idiomatic goal.

> We can achieve it only by increasing the use of signed types such as
> 'idx_t'. If we keep the old function, it needs to be marked with
> __attribute__ ((__deprecated__)), otherwise existing code will
> continue to use the old function forever.

My idea was that both APIs would be supported indefinitely.


Attachment: signature.asc
Description: PGP signature

reply via email to

[Prev in Thread] Current Thread [Next in Thread]