Re: [PATCH v1 1/5] cmd: Fix up warnings in flash.c
On Tue, Jan 04, 2022 at 02:23:57PM +0100, Patrick Delaunay wrote: > Tidy up the warnings reported by checkpatch.pl to prepare next patches > > Signed-off-by: Patrick Delaunay > Reviewed-by: Simon Glass > Reviewed-by: Stefan Roese Applied to u-boot/master, thanks! -- Tom signature.asc Description: PGP signature
Re: [PATCH v1 1/5] cmd: Fix up warnings in flash.c
On 1/4/22 14:23, Patrick Delaunay wrote: Tidy up the warnings reported by checkpatch.pl to prepare next patches Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass Reviewed-by: Stefan Roese Thanks, Stefan --- cmd/flash.c | 239 +--- 1 file changed, 117 insertions(+), 122 deletions(-) diff --git a/cmd/flash.c b/cmd/flash.c index 819febc10e..594e2caa59 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -19,7 +19,7 @@ int mtdparts_init(void); int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part); + u8 *part_num, struct part_info **part); #endif #ifdef CONFIG_MTD_NOR_FLASH @@ -47,34 +47,39 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ * or an invalid flash bank. */ static int -abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl) +abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl) { flash_info_t *fp; int bank, first, last; char *p, *ep; - if ((p = strchr (str, ':')) == NULL) + p = strchr(str, ':'); + if (!p) return 0; *p++ = '\0'; bank = dectoul(str, &ep); if (ep == str || *ep != '\0' || - bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS || - (fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN) + bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) + return -1; + + fp = &flash_info[bank - 1]; + if (fp->flash_id == FLASH_UNKNOWN) return -1; str = p; - if ((p = strchr (str, '-')) != NULL) + p = strchr(str, '-'); + if (p) *p++ = '\0'; first = dectoul(str, &ep); if (ep == str || *ep != '\0' || first >= fp->sector_count) return -1; - if (p != NULL) { + if (p) { last = dectoul(p, &ep); if (ep == p || *ep != '\0' || - last < first || last >= fp->sector_count) + last < first || last >= fp->sector_count) return -1; } else { last = first; @@ -107,11 +112,10 @@ int flash_sect_roundb(ulong *addr) sector_end_addr = info->start[0] + info->size - 1; } else { - sector_end_addr = info->start[i+1] - 1; + sector_end_addr = info->start[i + 1] - 1; } - if (*addr <= sector_end_addr && - *addr >= info->start[i]) { + if (*addr <= sector_end_addr && *addr >= info->start[i]) { found = 1; /* adjust *addr if necessary */ if (*addr < sector_end_addr) @@ -144,7 +148,7 @@ int flash_sect_roundb(ulong *addr) * Return: *1: success * -1: failure (bad format, bad address). -*/ + */ static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) { @@ -156,7 +160,7 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) return -1; len_used = 0; - if (arg2 && *arg2 == '+'){ + if (arg2 && *arg2 == '+') { len_used = 1; ++arg2; } @@ -165,7 +169,7 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) if (ep == arg2 || *ep != '\0') return -1; - if (len_used){ + if (len_used) { /* * *addr_last has the length, compute correct *addr_last * XXX watch out for the integer overflow! Right now it is @@ -187,9 +191,9 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) } static int -flash_fill_sect_ranges (ulong addr_first, ulong addr_last, - int *s_first, int *s_last, - int *s_count ) +flash_fill_sect_ranges(ulong addr_first, ulong addr_last, + int *s_first, int *s_last, + int *s_count) { flash_info_t *info; ulong bank; @@ -197,27 +201,25 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last, *s_count = 0; - for (bank=0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { s_first[bank] = -1; /* first sector to erase*/ - s_last [bank] = -1; /* last sector to erase*/ + s_last[bank] = -1; /* last sector to erase*/ } - for (bank=0,info = &flash_info[0]; + for (bank = 0, info = &flash_info[0
[PATCH v1 1/5] cmd: Fix up warnings in flash.c
Tidy up the warnings reported by checkpatch.pl to prepare next patches Signed-off-by: Patrick Delaunay Reviewed-by: Simon Glass --- cmd/flash.c | 239 +--- 1 file changed, 117 insertions(+), 122 deletions(-) diff --git a/cmd/flash.c b/cmd/flash.c index 819febc10e..594e2caa59 100644 --- a/cmd/flash.c +++ b/cmd/flash.c @@ -19,7 +19,7 @@ int mtdparts_init(void); int mtd_id_parse(const char *id, const char **ret_id, u8 *dev_type, u8 *dev_num); int find_dev_and_part(const char *id, struct mtd_device **dev, - u8 *part_num, struct part_info **part); + u8 *part_num, struct part_info **part); #endif #ifdef CONFIG_MTD_NOR_FLASH @@ -47,34 +47,39 @@ extern flash_info_t flash_info[]; /* info for FLASH chips */ * or an invalid flash bank. */ static int -abbrev_spec (char *str, flash_info_t ** pinfo, int *psf, int *psl) +abbrev_spec(char *str, flash_info_t **pinfo, int *psf, int *psl) { flash_info_t *fp; int bank, first, last; char *p, *ep; - if ((p = strchr (str, ':')) == NULL) + p = strchr(str, ':'); + if (!p) return 0; *p++ = '\0'; bank = dectoul(str, &ep); if (ep == str || *ep != '\0' || - bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS || - (fp = &flash_info[bank - 1])->flash_id == FLASH_UNKNOWN) + bank < 1 || bank > CONFIG_SYS_MAX_FLASH_BANKS) + return -1; + + fp = &flash_info[bank - 1]; + if (fp->flash_id == FLASH_UNKNOWN) return -1; str = p; - if ((p = strchr (str, '-')) != NULL) + p = strchr(str, '-'); + if (p) *p++ = '\0'; first = dectoul(str, &ep); if (ep == str || *ep != '\0' || first >= fp->sector_count) return -1; - if (p != NULL) { + if (p) { last = dectoul(p, &ep); if (ep == p || *ep != '\0' || - last < first || last >= fp->sector_count) + last < first || last >= fp->sector_count) return -1; } else { last = first; @@ -107,11 +112,10 @@ int flash_sect_roundb(ulong *addr) sector_end_addr = info->start[0] + info->size - 1; } else { - sector_end_addr = info->start[i+1] - 1; + sector_end_addr = info->start[i + 1] - 1; } - if (*addr <= sector_end_addr && - *addr >= info->start[i]) { + if (*addr <= sector_end_addr && *addr >= info->start[i]) { found = 1; /* adjust *addr if necessary */ if (*addr < sector_end_addr) @@ -144,7 +148,7 @@ int flash_sect_roundb(ulong *addr) * Return: *1: success * -1: failure (bad format, bad address). -*/ + */ static int addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) { @@ -156,7 +160,7 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) return -1; len_used = 0; - if (arg2 && *arg2 == '+'){ + if (arg2 && *arg2 == '+') { len_used = 1; ++arg2; } @@ -165,7 +169,7 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) if (ep == arg2 || *ep != '\0') return -1; - if (len_used){ + if (len_used) { /* * *addr_last has the length, compute correct *addr_last * XXX watch out for the integer overflow! Right now it is @@ -187,9 +191,9 @@ addr_spec(char *arg1, char *arg2, ulong *addr_first, ulong *addr_last) } static int -flash_fill_sect_ranges (ulong addr_first, ulong addr_last, - int *s_first, int *s_last, - int *s_count ) +flash_fill_sect_ranges(ulong addr_first, ulong addr_last, + int *s_first, int *s_last, + int *s_count) { flash_info_t *info; ulong bank; @@ -197,27 +201,25 @@ flash_fill_sect_ranges (ulong addr_first, ulong addr_last, *s_count = 0; - for (bank=0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { + for (bank = 0; bank < CONFIG_SYS_MAX_FLASH_BANKS; ++bank) { s_first[bank] = -1; /* first sector to erase*/ - s_last [bank] = -1; /* last sector to erase*/ + s_last[bank] = -1; /* last sector to erase*/ } - for (bank=0,info = &flash_info[0]; + for (bank = 0, info = &flash_info[0]; (bank < CONFIG_SYS_MAX_FLASH_BANKS) && (add