Staging: ks7010: michael_mic: fixed macros coding style issue
PATCH 1/1 Staging: ks7010: michael_mic: fixed macros coding style issue
Fixed coding style issue:
Enclose multiple statements macros definition in a do while loop. Use one space around binary operators.
Signed-off-by Bing Sun <[email protected]>
--- drivers/staging/ks7010/michael_mic.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)
drivers/staging/ks7010/michael_mic.c +13 -7
@@ -20,15 +20,21 @@#define getUInt32 (A ,B ) (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24)// Convert from UInt32 to Byte[] in a portable way -#define putUInt32 (A ,B ,C ) A[B+0] = (uint8_t) (C & 0xff); \ - A[B+1] = (uint8_t) ((C>>8) & 0xff); \ - A[B+2] = (uint8_t) ((C>>16) & 0xff); \ - A[B+3] = (uint8_t) ((C>>24) & 0xff) +#define putUInt32 (A ,B ,C ) \ +do { \ + A[B + 0] = (uint8_t)(C & 0xff); \ + A[B + 1] = (uint8_t)((C >> 8) & 0xff); \ + A[B + 2] = (uint8_t)((C >> 16) & 0xff); \ + A[B + 3] = (uint8_t)((C >> 24) & 0xff); \ +} while (0)// Reset the state to the empty message. -#define MichaelClear (A ) A->L = A->K0; \ - A->R = A->K1; \ - A->nBytesInM = 0; +#define MichaelClear (A ) \ +do { \ + A->L = A->K0; \ + A->R = A->K1; \ + A->nBytesInM = 0; \ +} while (0)static void MichaelInitializeFunction (struct michel_mic_t *Mic,uint8_t * key)
Signature · 1 line
2.1.0
Quoted 5 lines · Bing Sun
Fixed coding style issue:
Enclose multiple statements macros definition in a do while loop. Use one space around binary operators.Signed-off-by Bing Sun <[email protected]>
Looks good for what it is. One comment below. I will test this tomorrow.
Quoted 13 lines
--- drivers/staging/ks7010/michael_mic.c | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-)drivers/staging/ks7010/michael_mic.c +0
-1@@ -20,15 +20,21 @@#define getUInt32 (A ,B ) (uint32_t)(A[B+0] << 0) + (A[B+1] << 8) + (A[B+2] << 16) + (A[B+3] << 24)// Convert from UInt32 to Byte[] in a portable way -#define putUInt32 (A ,B ,C ) A[B+0] = (uint8_t) (C & 0xff); \
drivers/staging/ks7010/michael_mic.c line 29
Quoted 10 lines
drivers/staging/ks7010/michael_mic.c +7
-3-A [B +1 ] = (uint8_t ) ((C >>8 ) &0xff ); \ -A [B +2 ] = (uint8_t ) ((C >>16 ) &0xff ); \ -A [B +3 ] = (uint8_t ) ((C >>24 ) &0xff ) +#define putUInt32 (A ,B ,C ) \ +do { \ + A[B + 0] = (uint8_t)(C & 0xff); \ + A[B + 1] = (uint8_t)((C >> 8) & 0xff); \ + A[B + 2] = (uint8_t)((C >> 16) & 0xff); \ + A[B + 3] = (uint8_t)((C >> 24) & 0xff); \ +} while (0)
We surely have helper functions for this in the kernel?
Quoted 17 lines
drivers/staging/ks7010/michael_mic.c +6
-3// Reset the state to the empty message. -#define MichaelClear (A ) A->L = A->K0; \ - A->R = A->K1; \ - A->nBytesInM = 0; +#define MichaelClear (A ) \ +do { \ + A->L = A->K0; \ + A->R = A->K1; \ + A->nBytesInM = 0; \ +} while (0)static void MichaelInitializeFunction (struct michel_mic_t *Mic,uint8_t * key)Signature · 1 line
2.1.0
Quoted 5 lines · Bing Sun
Fixed coding style issue:
Enclose multiple statements macros definition in a do while loop. Use one space around binary operators.Signed-off-by Bing Sun <[email protected]>
Reviewed-by Wolfram Sang <[email protected]>