Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1445986 > unrolled thread
| Started by | Bing Sun <sunbing@redflag-linux.com> |
|---|---|
| First post | 2016-07-19 04:00 +0200 |
| Last post | 2016-07-21 19:00 +0200 |
| Articles | 3 — 2 participants |
Back to article view | Back to linux.kernel
[PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue Bing Sun <sunbing@redflag-linux.com> - 2016-07-19 04:00 +0200
Re: [PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue Wolfram Sang <wsa@the-dreams.de> - 2016-07-20 18:10 +0200
Re: [PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue Wolfram Sang <wsa@the-dreams.de> - 2016-07-21 19:00 +0200
| From | Bing Sun <sunbing@redflag-linux.com> |
|---|---|
| Date | 2016-07-19 04:00 +0200 |
| Subject | [PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue |
| Message-ID | <rWsud-5Q5-3@gated-at.bofh.it> |
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 <sunbing@redflag-linux.com>
---
drivers/staging/ks7010/michael_mic.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
index e14c109..d332678 100644
--- a/drivers/staging/ks7010/michael_mic.c
+++ b/drivers/staging/ks7010/michael_mic.c
@@ -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)
--
2.1.0
[toc] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-07-20 18:10 +0200 |
| Subject | Re: [PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue |
| Message-ID | <rX2em-3Bs-23@gated-at.bofh.it> |
| In reply to | #1445986 |
[Multipart message — attachments visible in raw view] — view raw
On Tue, Jul 19, 2016 at 09:51:06AM +0800, Bing Sun wrote:
> 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 <sunbing@redflag-linux.com>
Looks good for what it is. One comment below. I will test this tomorrow.
> ---
> drivers/staging/ks7010/michael_mic.c | 20 +++++++++++++-------
> 1 file changed, 13 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/staging/ks7010/michael_mic.c b/drivers/staging/ks7010/michael_mic.c
> index e14c109..d332678 100644
> --- a/drivers/staging/ks7010/michael_mic.c
> +++ b/drivers/staging/ks7010/michael_mic.c
> @@ -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)
We surely have helper functions for this in the kernel?
>
> // 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)
> --
> 2.1.0
>
[toc] | [prev] | [next] | [standalone]
| From | Wolfram Sang <wsa@the-dreams.de> |
|---|---|
| Date | 2016-07-21 19:00 +0200 |
| Subject | Re: [PATCH] Staging: ks7010: michael_mic: fixed macros coding style issue |
| Message-ID | <rXpuj-1Dd-61@gated-at.bofh.it> |
| In reply to | #1445986 |
On Tue, Jul 19, 2016 at 09:51:06AM +0800, Bing Sun wrote: > 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 <sunbing@redflag-linux.com> Reviewed-by: Wolfram Sang <wsa@the-dreams.de>
[toc] | [prev] | [standalone]
Back to top | Article view | linux.kernel
csiph-web