Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 07 Apr 2013 16:31:37 +0200
From: Jens Gustedt <jens.gustedt@...ia.fr>
To: musl@...ts.openwall.com
Subject: Re: [PATCH] String: expand to word size && refactor ||
 refactor

Am Sonntag, den 07.04.2013, 15:29 +0200 schrieb Szabolcs Nagy:
> * Jens Gustedt <jens.gustedt@...ia.fr> [2013-04-07 11:38:48 +0200]:
> > Am Sonntag, den 07.04.2013, 11:23 +0200 schrieb Szabolcs Nagy:
> > > #define ONES ((size_t)-1/255)
> > 
> > just a nitpick, wouldn't
> > 
> > #define ONES (SIZE_MAX/255)
> > 
> > be clearer
> 
> it is two chars shorter at least :)
> 
> the unsigned -1 idiom is used a lot in musl anyway

hm, for macros I really would be more cautious. Couldn't one day such
a macro end up in a #if directive? Then using the named macro would be
better since this then gives the same value for the
preprocessor.

(size_t)-1 is wrong because this would be -1 for the preprocessor. So
it should at least be (size_t)-1U to ensure that this is an unsigned
integer even in the preprocessor. But this would give a different
value, still, if size_t is narrower than uintmax_t.

> the really clear definition would be (size_t)0x0101..01 but it
> depends on the word size

that should be (size_t)+0x0101..01 such that it can be evaluated in
the preprocessor.

Jens

-- 
:: INRIA Nancy Grand Est :: http://www.loria.fr/~gustedt/   ::
:: AlGorille ::::::::::::::: office Nancy : +33 383593090   ::
:: ICube :::::::::::::: office Strasbourg : +33 368854536   ::
:: ::::::::::::::::::::::::::: gsm France : +33 651400183   ::
:: :::::::::::::::::::: gsm international : +49 15737185122 ::



Download attachment "signature.asc" of type "application/pgp-signature" (199 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.