Dubious #define in include/pwd.h

Steven Smith sos22 at cantab.net
Wed Jan 26 02:08:44 PST 2005


> > I was messing around with sparse, the static checker used sometimes
> > by Linux kernel people, and I (or rather, it) came upon the line
> >
> > #define _PW_VERSION_MASK        '0xF0'
> >
> > in /usr/src/include/pwd.h.  I can't immediately see any use for this;
> > '\xf0' would probably be more useful.
> If this is used as a mask for 'unsigned char' values, why would it make
> any difference?  Aren't they both going to be implicitly converted to
> the right typep anyway?
Well, except for the single quotes around '0xf0'.  If you go:

int x = '0xf0';
printf("%d\n", x);

you probably won't get what you expect.  If you replace the '0xf0'
with '\xf0' you probably will.

Steven.
-- 
'Double-entry bookkeeping ....simple to adapt to modern computer
methods by using positive or negative electric charges to signal
whether an account should be debited or credited.'
  -- Accounting Theory and Practice, Glautier M.W.E
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 187 bytes
Desc: not available
Url : http://lists.freebsd.org/pipermail/freebsd-bugs/attachments/20050126/b6985ab9/attachment.bin


More information about the freebsd-bugs mailing list