Subject: Re: magic symlinks: uid keyword translation
To: None <tech-kern@NetBSD.org>
From: Alan Barrett <apb@cequrux.com>
List: tech-kern
Date: 10/30/2006 18:10:13
On Mon, 30 Oct 2006, Stephen Borrill wrote:
> It's numeric UID not user name, so 16 will be fine.

11 would be enough for unsigned 32-bit uid_t.  16 is not enough for
64-bit uid_t, so the choice of 16 seems rather arbitrary to me.

Perhaps we should define something like

    #define __MAX_DIGITS_FOR_UNSIGNED_TYPE(t) \
	((sizeof(t) * CHAR_BIT + 2) / 3)
    #define __MAX_DIGITS_FOR_SIGNED_TYPE(t) \
	((sizeof(t) * CHAR_BIT + 2) / 3 + 1)

and then people could do

    char buf[__MAX_DIGITS_FOR_UNSIGNED_TYPE(uid_t) + 1];

--apb (Alan Barrett)