mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-09 17:38:00 +00:00
Add casts to silence VS warnings in GET_32BIT et al.
Visual Studio is quite aggressive about displaying warnings everywhere that you implicitly narrow from one integer type to another, and I've not generally felt it improves readability to add enough explicit casts to silence the warnings. But the ones in the inline functions in misc.h are literally two orders of magnitude more annoying than the rest, because that file gets included in nearly every translation unit, so the warnings come up over 100 times each. So I think these are worth fixing.
This commit is contained in:
parent
1bcf2a8397
commit
ce780c9b33
56
misc.h
56
misc.h
@ -276,14 +276,14 @@ static inline uint64_t GET_64BIT_LSB_FIRST(const void *vp)
|
||||
static inline void PUT_64BIT_LSB_FIRST(void *vp, uint64_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[0] = value;
|
||||
p[1] = (value) >> 8;
|
||||
p[2] = (value) >> 16;
|
||||
p[3] = (value) >> 24;
|
||||
p[4] = (value) >> 32;
|
||||
p[5] = (value) >> 40;
|
||||
p[6] = (value) >> 48;
|
||||
p[7] = (value) >> 56;
|
||||
p[0] = (uint8_t)(value);
|
||||
p[1] = (uint8_t)(value >> 8);
|
||||
p[2] = (uint8_t)(value >> 16);
|
||||
p[3] = (uint8_t)(value >> 24);
|
||||
p[4] = (uint8_t)(value >> 32);
|
||||
p[5] = (uint8_t)(value >> 40);
|
||||
p[6] = (uint8_t)(value >> 48);
|
||||
p[7] = (uint8_t)(value >> 56);
|
||||
}
|
||||
|
||||
static inline uint32_t GET_32BIT_LSB_FIRST(const void *vp)
|
||||
@ -296,10 +296,10 @@ static inline uint32_t GET_32BIT_LSB_FIRST(const void *vp)
|
||||
static inline void PUT_32BIT_LSB_FIRST(void *vp, uint32_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[0] = value;
|
||||
p[1] = (value) >> 8;
|
||||
p[2] = (value) >> 16;
|
||||
p[3] = (value) >> 24;
|
||||
p[0] = (uint8_t)(value);
|
||||
p[1] = (uint8_t)(value >> 8);
|
||||
p[2] = (uint8_t)(value >> 16);
|
||||
p[3] = (uint8_t)(value >> 24);
|
||||
}
|
||||
|
||||
static inline uint16_t GET_16BIT_LSB_FIRST(const void *vp)
|
||||
@ -311,8 +311,8 @@ static inline uint16_t GET_16BIT_LSB_FIRST(const void *vp)
|
||||
static inline void PUT_16BIT_LSB_FIRST(void *vp, uint16_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[0] = value;
|
||||
p[1] = (value) >> 8;
|
||||
p[0] = (uint8_t)(value);
|
||||
p[1] = (uint8_t)(value >> 8);
|
||||
}
|
||||
|
||||
static inline uint64_t GET_64BIT_MSB_FIRST(const void *vp)
|
||||
@ -327,14 +327,14 @@ static inline uint64_t GET_64BIT_MSB_FIRST(const void *vp)
|
||||
static inline void PUT_64BIT_MSB_FIRST(void *vp, uint64_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[7] = value;
|
||||
p[6] = (value) >> 8;
|
||||
p[5] = (value) >> 16;
|
||||
p[4] = (value) >> 24;
|
||||
p[3] = (value) >> 32;
|
||||
p[2] = (value) >> 40;
|
||||
p[1] = (value) >> 48;
|
||||
p[0] = (value) >> 56;
|
||||
p[7] = (uint8_t)(value);
|
||||
p[6] = (uint8_t)(value >> 8);
|
||||
p[5] = (uint8_t)(value >> 16);
|
||||
p[4] = (uint8_t)(value >> 24);
|
||||
p[3] = (uint8_t)(value >> 32);
|
||||
p[2] = (uint8_t)(value >> 40);
|
||||
p[1] = (uint8_t)(value >> 48);
|
||||
p[0] = (uint8_t)(value >> 56);
|
||||
}
|
||||
|
||||
static inline uint32_t GET_32BIT_MSB_FIRST(const void *vp)
|
||||
@ -347,10 +347,10 @@ static inline uint32_t GET_32BIT_MSB_FIRST(const void *vp)
|
||||
static inline void PUT_32BIT_MSB_FIRST(void *vp, uint32_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[3] = value;
|
||||
p[2] = (value) >> 8;
|
||||
p[1] = (value) >> 16;
|
||||
p[0] = (value) >> 24;
|
||||
p[3] = (uint8_t)(value);
|
||||
p[2] = (uint8_t)(value >> 8);
|
||||
p[1] = (uint8_t)(value >> 16);
|
||||
p[0] = (uint8_t)(value >> 24);
|
||||
}
|
||||
|
||||
static inline uint16_t GET_16BIT_MSB_FIRST(const void *vp)
|
||||
@ -362,8 +362,8 @@ static inline uint16_t GET_16BIT_MSB_FIRST(const void *vp)
|
||||
static inline void PUT_16BIT_MSB_FIRST(void *vp, uint16_t value)
|
||||
{
|
||||
uint8_t *p = (uint8_t *)vp;
|
||||
p[1] = value;
|
||||
p[0] = (value) >> 8;
|
||||
p[1] = (uint8_t)(value);
|
||||
p[0] = (uint8_t)(value >> 8);
|
||||
}
|
||||
|
||||
/* Replace NULL with the empty string, permitting an idiom in which we
|
||||
|
Loading…
Reference in New Issue
Block a user