simo idra at samba.org
Sat Mar 12 11:20:19 MST 2011

On Fri, 2011-03-11 at 04:32 -0500, Christoph Hellwig wrote:
> On Fri, Mar 11, 2011 at 10:56:42AM +1100, tridge at samba.org wrote:
> > Hi Christoph,
> > 
> >  > Did you guys ever look into the sparse address space annotations?
> > 
> > can sparse be used to warn about mixing of different integer types? 
> Yes.
> > I so, that could be _really_ useful! We could get rid of the NTSTATUS
> > structure in that case as well.
> > 
> > looking at the sparse manpage, I think we'd need to declare NTTIME and
> > NTSTATUS as being __attribute__((bitwise)), then use -Wbitwise with
> > sparse. Does that sound right?
> Exactly.  E.g. from the Linux kernel code for the little/big-endian
> types (it requires -D__CHECK_ENDIAN__ to actually check endianess even
> with sparse for historic reasons):
> include/linux/types.h:
> #ifdef __CHECKER__
> #define __bitwise__ __attribute__((bitwise))
> #else
> #define __bitwise__
> #endif
> #ifdef __CHECK_ENDIAN__
> #define __bitwise __bitwise__
> #else
> #define __bitwise
> #endif
> typedef __u16 __bitwise __le16;
> typedef __u16 __bitwise __be16;
> typedef __u32 __bitwise __le32;
> typedef __u32 __bitwise __be32;
> typedef __u64 __bitwise __le64;
> typedef __u64 __bitwise __be64;
> and then the (be|le)*_to_cpu/cpu_to_(be|le)* require casts in their
> actual bit-swap operations.
> Note that bitwise also disallows arithmetic operations on these types.
> I'm not sure how much of an issue that is for your NTTIME use case -
> arithmetics on time values makes sense in theory, but I'm not sure how
> common it is.

Operations on time values are used to calculate offsets, or set timers
and the like.
Although we mostly do that on time_t values.

Perhaps we can have macros (with suitable internal casts) for the cases
where we need to do some addition or subtractions on NTTIME values ...

Macros are probably going to be a good idea for that kind of operations
on nt time values anyway.


Simo Sorce
Samba Team GPL Compliance Officer <simo at samba.org>
Principal Software Engineer at Red Hat, Inc. <simo at redhat.com>

More information about the samba-technical mailing list