aboutsummaryrefslogtreecommitdiff
path: root/src/flash/nor/cfi.c
diff options
context:
space:
mode:
authorAntonio Borneo <borneo.antonio@gmail.com>2021-07-03 18:51:20 +0200
committerAntonio Borneo <borneo.antonio@gmail.com>2021-07-24 10:37:49 +0100
commit08ee7bb982b16742f52cfdc6c649d82ffa2eb177 (patch)
treea824d376b774499303f00cffb201e35b01830d98 /src/flash/nor/cfi.c
parentb159f5cdedd70fff9309722e927be670845f4df5 (diff)
downloadriscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.zip
riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.gz
riscv-openocd-08ee7bb982b16742f52cfdc6c649d82ffa2eb177.tar.bz2
openocd: fix simple cases of NULL comparison
There are more than 1000 NULL comparisons to be aligned to the coding style. For recurrent NULL comparison it's preferable using trivial scripts in order to minimize the review effort. Patch generated automatically with the command: sed -i PATTERN $(find src/ -type f) where PATTERN is in the list: 's/(\([a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) == NULL)/(!\1)/g' 's/(\([a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(\([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\) != NULL)/(\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL == \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(!\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*->[a-z][a-z0-9_]*\))/(\1)/g' 's/(NULL != \([a-z][a-z0-9_]*\.[a-z][a-z0-9_]*\))/(\1)/g' Change-Id: Ida103e325d6d0600fb69c0b7a1557ee969db4417 Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com> Reviewed-on: http://openocd.zylin.com/6350 Tested-by: jenkins
Diffstat (limited to 'src/flash/nor/cfi.c')
-rw-r--r--src/flash/nor/cfi.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/flash/nor/cfi.c b/src/flash/nor/cfi.c
index a03179a..830d3e3 100644
--- a/src/flash/nor/cfi.c
+++ b/src/flash/nor/cfi.c
@@ -426,7 +426,7 @@ static int cfi_read_intel_pri_ext(struct flash_bank *bank)
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_intel_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -522,7 +522,7 @@ static int cfi_read_spansion_pri_ext(struct flash_bank *bank)
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -624,7 +624,7 @@ static int cfi_read_atmel_pri_ext(struct flash_bank *bank)
free(cfi_info->pri_ext);
pri_ext = malloc(sizeof(struct cfi_spansion_pri_ext));
- if (pri_ext == NULL) {
+ if (!pri_ext) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -811,7 +811,7 @@ int cfi_flash_bank_cmd(struct flash_bank *bank, unsigned int argc, const char **
}
cfi_info = calloc(1, sizeof(struct cfi_flash_bank));
- if (cfi_info == NULL) {
+ if (!cfi_info) {
LOG_ERROR("No memory for flash bank info");
return ERROR_FAIL;
}
@@ -1488,7 +1488,7 @@ static int cfi_spansion_write_block_mips(struct flash_bank *bank, const uint8_t
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}
@@ -1867,7 +1867,7 @@ static int cfi_spansion_write_block(struct flash_bank *bank, const uint8_t *buff
/* convert bus-width dependent algorithm code to correct endianness */
target_code = malloc(target_code_size);
- if (target_code == NULL) {
+ if (!target_code) {
LOG_ERROR("Out of memory");
return ERROR_FAIL;
}