diff options
author | Jeremy Allison <jra@samba.org> | 2002-01-11 19:10:25 +0000 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2002-01-11 19:10:25 +0000 |
commit | d6823366b881612234ab0655adb11c594f864c4a (patch) | |
tree | 325ac7bc1ac5aa03c28319501b891a99991357cf /source3/include | |
parent | 27655be3c1708d447b046a2b0d8b2013eeb21835 (diff) | |
download | samba-d6823366b881612234ab0655adb11c594f864c4a.tar.gz samba-d6823366b881612234ab0655adb11c594f864c4a.tar.bz2 samba-d6823366b881612234ab0655adb11c594f864c4a.zip |
Same fix as went into 2.2 (I'm waiting for jerry to finish some code).
Jeremy.
(This used to be commit 01ff6ce4963e1daff019f2b936cef218e1c93f67)
Diffstat (limited to 'source3/include')
-rw-r--r-- | source3/include/byteorder.h | 42 |
1 files changed, 24 insertions, 18 deletions
diff --git a/source3/include/byteorder.h b/source3/include/byteorder.h index e6cce73ceb..fab77060be 100644 --- a/source3/include/byteorder.h +++ b/source3/include/byteorder.h @@ -106,23 +106,25 @@ it also defines lots of intermediate macros, just ignore those :-) #define CAREFUL_ALIGNMENT 1 #endif -#define CVAL(buf,pos) (((unsigned char *)(buf))[pos]) -#define PVAL(buf,pos) ((unsigned)CVAL(buf,pos)) -#define SCVAL(buf,pos,val) (CVAL(buf,pos) = (val)) +#define CVAL(buf,pos) (((const unsigned char *)(buf))[pos]) +#define CVAL_NC(buf,pos) (((unsigned char *)(buf))[pos]) /* Non-const version of CVAL */ +#define PVAL(buf,pos) ((const unsigned)CVAL(buf,pos)) +#define PVAL_NC(buf,pos) ((unsigned)CVAL(buf,pos)) /* Non const version of PVAL */ +#define SCVAL(buf,pos,val) (CVAL_NC(buf,pos) = (val)) #if CAREFUL_ALIGNMENT #define SVAL(buf,pos) (PVAL(buf,pos)|PVAL(buf,(pos)+1)<<8) #define IVAL(buf,pos) (SVAL(buf,pos)|SVAL(buf,(pos)+2)<<16) -#define SSVALX(buf,pos,val) (CVAL(buf,pos)=(val)&0xFF,CVAL(buf,pos+1)=(val)>>8) +#define SSVALX(buf,pos,val) (CVAL_NC(buf,pos)=(val)&0xFF,CVAL_NC(buf,pos+1)=(val)>>8) #define SIVALX(buf,pos,val) (SSVALX(buf,pos,val&0xFFFF),SSVALX(buf,pos+2,val>>16)) -#define SVALS(buf,pos) ((int16)SVAL(buf,pos)) -#define IVALS(buf,pos) ((int32)IVAL(buf,pos)) -#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((uint16)(val))) -#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((uint32)(val))) -#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((int16)(val))) -#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((int32)(val))) +#define SVALS(buf,pos) ((const int16)SVAL(buf,pos)) +#define IVALS(buf,pos) ((const int32)IVAL(buf,pos)) +#define SSVAL(buf,pos,val) SSVALX((buf),(pos),((const uint16)(val))) +#define SIVAL(buf,pos,val) SIVALX((buf),(pos),((const uint32)(val))) +#define SSVALS(buf,pos,val) SSVALX((buf),(pos),((const int16)(val))) +#define SIVALS(buf,pos,val) SIVALX((buf),(pos),((const int32)(val))) #else /* CAREFUL_ALIGNMENT */ @@ -134,16 +136,20 @@ it also defines lots of intermediate macros, just ignore those :-) */ /* get single value from an SMB buffer */ -#define SVAL(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) -#define IVAL(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) -#define SVALS(buf,pos) (*(int16 *)((char *)(buf) + (pos))) -#define IVALS(buf,pos) (*(int32 *)((char *)(buf) + (pos))) +#define SVAL(buf,pos) (*(const uint16 *)((const char *)(buf) + (pos))) +#define SVAL_NC(buf,pos) (*(uint16 *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define IVAL(buf,pos) (*(const uint32 *)((const char *)(buf) + (pos))) +#define IVAL_NC(buf,pos) (*(uint32 *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define SVALS(buf,pos) (*(const int16 *)((const char *)(buf) + (pos))) +#define SVALS_NC(buf,pos) (*(int16 *)((char *)(buf) + (pos))) /* Non const version of above. */ +#define IVALS(buf,pos) (*(const int32 *)((const char *)(buf) + (pos))) +#define IVALS_NC(buf,pos) (*(int32 *)((char *)(buf) + (pos))) /* Non const version of above. */ /* store single value in an SMB buffer */ -#define SSVAL(buf,pos,val) SVAL(buf,pos)=((uint16)(val)) -#define SIVAL(buf,pos,val) IVAL(buf,pos)=((uint32)(val)) -#define SSVALS(buf,pos,val) SVALS(buf,pos)=((int16)(val)) -#define SIVALS(buf,pos,val) IVALS(buf,pos)=((int32)(val)) +#define SSVAL(buf,pos,val) SVAL_NC(buf,pos)=((const uint16)(val)) +#define SIVAL(buf,pos,val) IVAL_NC(buf,pos)=((const uint32)(val)) +#define SSVALS(buf,pos,val) SVALS_NC(buf,pos)=((const int16)(val)) +#define SIVALS(buf,pos,val) IVALS_NC(buf,pos)=((const int32)(val)) #endif /* CAREFUL_ALIGNMENT */ |