Re: [PATCH] hw/block: replace TABs with space Bring the block files in line with the QEMU coding style, with spaces for indentation. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/371

2023-03-10 Thread Eric Blake
Missing the blank line between the one-line summary and the rest of
the commit body, which killed the subject line.

You now have multiple threads referencing gitlab issue 371; maybe
instead of saying 'Resolves:', you should just mention that each patch
is a partial resolution (since one patch in isolation is obviously not
resolving it tree-wide, if you have other series referencing the same
bug).

On Fri, Mar 10, 2023 at 06:31:49PM +0800, Yeqi Fu wrote:
> Signed-off-by: Yeqi Fu 
> ---
>  hw/block/fdc.c |   4 +-
>  hw/block/nand.c| 222 ++---
>  hw/block/onenand.c | 126 -
>  hw/block/tc58128.c | 136 +--
>  4 files changed, 244 insertions(+), 244 deletions(-)
> 

> +++ b/hw/block/onenand.c
> @@ -35,10 +35,10 @@
>  #include "qom/object.h"
>  
>  /* 11 for 2kB-page OneNAND ("2nd generation") and 10 for 1kB-page chips */
> -#define PAGE_SHIFT   11
> +#define PAGE_SHIFT 11
>  
>  /* Fixed */
> -#define BLOCK_SHIFT  (PAGE_SHIFT + 6)
> +#define BLOCK_SHIFT (PAGE_SHIFT + 6)
>  
>  #define TYPE_ONE_NAND "onenand"
>  OBJECT_DECLARE_SIMPLE_TYPE(OneNANDState, ONE_NAND)
> @@ -408,23 +408,23 @@ static void onenand_command(OneNANDState *s)
>  int b;
>  int sec;
>  void *buf;
> -#define SETADDR(block, page) \
> -sec = (s->addr[page] & 3) +  \
> -s->addr[page] >> 2) & 0x3f) +\
> -  (((s->addr[block] & 0xfff) |   \
> -(s->addr[block] >> 15 ?  \

The old code had aligned '\' (harder to see when diff's prefix messes
up tab stops)...

> +#define SETADDR(block, page)\
> +sec = (s->addr[page] & 3) + \
> +s->addr[page] >> 2) & 0x3f) +   \
> +  (((s->addr[block] & 0xfff) |  \
> +(s->addr[block] >> 15 ? \
>   s->density_mask : 0)) << 6)) << (PAGE_SHIFT - 9));

...but the spacing on the new-code is inconsistent.  Whereas I'm
ambivalent on aligned '=' in struct initializations, when it comes to
preprocessor macros, I'm very much a fan of using aligned '\'.

You may also want to mention that 'git diff -w ...' shows no change,
proving that the patch is whitespace only (or if it does show change,
that it is because you rewrapped lines).

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.   +1-919-301-3266
Virtualization:  qemu.org | libvirt.org




[PATCH] hw/block: replace TABs with space Bring the block files in line with the QEMU coding style, with spaces for indentation. Resolves: https://gitlab.com/qemu-project/qemu/-/issues/371

2023-03-10 Thread Yeqi Fu
Signed-off-by: Yeqi Fu 
---
 hw/block/fdc.c |   4 +-
 hw/block/nand.c| 222 ++---
 hw/block/onenand.c | 126 -
 hw/block/tc58128.c | 136 +--
 4 files changed, 244 insertions(+), 244 deletions(-)

diff --git a/hw/block/fdc.c b/hw/block/fdc.c
index 64ae4a6899..d7cc4d3ec1 100644
--- a/hw/block/fdc.c
+++ b/hw/block/fdc.c
@@ -601,8 +601,8 @@ enum {
 };
 
 enum {
-FD_STATE_MULTI  = 0x01,/* multi track flag */
-FD_STATE_FORMAT = 0x02,/* format flag */
+FD_STATE_MULTI  = 0x01, /* multi track flag */
+FD_STATE_FORMAT = 0x02, /* format flag */
 };
 
 enum {
diff --git a/hw/block/nand.c b/hw/block/nand.c
index 1aee1cb2b1..79832b9cd5 100644
--- a/hw/block/nand.c
+++ b/hw/block/nand.c
@@ -30,33 +30,33 @@
 #include "qemu/module.h"
 #include "qom/object.h"
 
-# define NAND_CMD_READ00x00
-# define NAND_CMD_READ10x01
-# define NAND_CMD_READ20x50
-# define NAND_CMD_LPREAD2  0x30
-# define NAND_CMD_NOSERIALREAD20x35
-# define NAND_CMD_RANDOMREAD1  0x05
-# define NAND_CMD_RANDOMREAD2  0xe0
-# define NAND_CMD_READID   0x90
-# define NAND_CMD_RESET0xff
-# define NAND_CMD_PAGEPROGRAM1 0x80
-# define NAND_CMD_PAGEPROGRAM2 0x10
-# define NAND_CMD_CACHEPROGRAM20x15
-# define NAND_CMD_BLOCKERASE1  0x60
-# define NAND_CMD_BLOCKERASE2  0xd0
-# define NAND_CMD_READSTATUS   0x70
-# define NAND_CMD_COPYBACKPRG1 0x85
-
-# define NAND_IOSTATUS_ERROR   (1 << 0)
-# define NAND_IOSTATUS_PLANE0  (1 << 1)
-# define NAND_IOSTATUS_PLANE1  (1 << 2)
-# define NAND_IOSTATUS_PLANE2  (1 << 3)
-# define NAND_IOSTATUS_PLANE3  (1 << 4)
+# define NAND_CMD_READ0 0x00
+# define NAND_CMD_READ1 0x01
+# define NAND_CMD_READ2 0x50
+# define NAND_CMD_LPREAD2   0x30
+# define NAND_CMD_NOSERIALREAD2 0x35
+# define NAND_CMD_RANDOMREAD1   0x05
+# define NAND_CMD_RANDOMREAD2   0xe0
+# define NAND_CMD_READID0x90
+# define NAND_CMD_RESET 0xff
+# define NAND_CMD_PAGEPROGRAM1  0x80
+# define NAND_CMD_PAGEPROGRAM2  0x10
+# define NAND_CMD_CACHEPROGRAM2 0x15
+# define NAND_CMD_BLOCKERASE1   0x60
+# define NAND_CMD_BLOCKERASE2   0xd0
+# define NAND_CMD_READSTATUS0x70
+# define NAND_CMD_COPYBACKPRG1  0x85
+
+# define NAND_IOSTATUS_ERROR(1 << 0)
+# define NAND_IOSTATUS_PLANE0   (1 << 1)
+# define NAND_IOSTATUS_PLANE1   (1 << 2)
+# define NAND_IOSTATUS_PLANE2   (1 << 3)
+# define NAND_IOSTATUS_PLANE3   (1 << 4)
 # define NAND_IOSTATUS_READY(1 << 6)
-# define NAND_IOSTATUS_UNPROTCT(1 << 7)
+# define NAND_IOSTATUS_UNPROTCT (1 << 7)
 
-# define MAX_PAGE  0x800
-# define MAX_OOB   0x40
+# define MAX_PAGE   0x800
+# define MAX_OOB0x40
 
 typedef struct NANDFlashState NANDFlashState;
 struct NANDFlashState {
@@ -102,40 +102,40 @@ static void mem_and(uint8_t *dest, const uint8_t *src, 
size_t n)
 }
 }
 
-# define NAND_NO_AUTOINCR  0x0001
-# define NAND_BUSWIDTH_16  0x0002
-# define NAND_NO_PADDING   0x0004
-# define NAND_CACHEPRG 0x0008
-# define NAND_COPYBACK 0x0010
-# define NAND_IS_AND   0x0020
-# define NAND_4PAGE_ARRAY  0x0040
-# define NAND_NO_READRDY   0x0100
-# define NAND_SAMSUNG_LP   (NAND_NO_PADDING | NAND_COPYBACK)
+# define NAND_NO_AUTOINCR   0x0001
+# define NAND_BUSWIDTH_16   0x0002
+# define NAND_NO_PADDING0x0004
+# define NAND_CACHEPRG  0x0008
+# define NAND_COPYBACK  0x0010
+# define NAND_IS_AND0x0020
+# define NAND_4PAGE_ARRAY   0x0040
+# define NAND_NO_READRDY0x0100
+# define NAND_SAMSUNG_LP(NAND_NO_PADDING | NAND_COPYBACK)
 
 # define NAND_IO
 
-# define PAGE(addr)((addr) >> ADDR_SHIFT)
-# define PAGE_START(page)   (PAGE(page) * (NAND_PAGE_SIZE + OOB_SIZE))
-# define PAGE_MASK ((1 << ADDR_SHIFT) - 1)
-# define OOB_SHIFT (PAGE_SHIFT - 5)
-# define OOB_SIZE  (1 << OOB_SHIFT)
-# define SECTOR(addr)  ((addr) >> (9 + ADDR_SHIFT - PAGE_SHIFT))
-# define SECTOR_OFFSET(addr)   ((addr) & ((511 >> PAGE_SHIFT) << 8))
-
-# define NAND_PAGE_SIZE 256
-# define PAGE_SHIFT8
-# define PAGE_SECTORS  1
-# define ADDR_SHIFT8
+# define PAGE(addr)  ((addr) >> ADDR_SHIFT)
+# define PAGE_START(page)(PAGE(page) * (NAND_PAGE_SIZE + OOB_SIZE))
+# define PAGE_MASK   ((1 << ADDR_SHIFT) - 1)
+# define OOB_SHIFT   (PAGE_SHIFT - 5)
+# define OOB_SIZE(1 << OOB_SHIFT)
+# define SECTOR(addr)((addr) >> (9 + ADDR_SHIFT - PAGE_SHIFT))
+# define SECTOR_OFFSET(addr) ((addr) & ((511 >> PAGE_SHIFT) << 8))
+
+# define NAND_PAGE_SIZE 256
+# define PAGE_SHIFT 8
+# define PAGE_SECTORS   1
+# define ADDR_SHIFT 8
 # include "nand.c"
-# define NAND_PAGE_SIZE 512
-# define PAGE_SHIFT