openocd: remove NULL comparisons with checkpatch [2/2] 52/6352/3
authorAntonio Borneo <borneo.antonio@gmail.com>
Sat, 3 Jul 2021 19:47:55 +0000 (21:47 +0200)
committerAntonio Borneo <borneo.antonio@gmail.com>
Sat, 24 Jul 2021 09:38:11 +0000 (10:38 +0100)
Patch generated automatically through a modified checkpatch that
detects the patterns
if (NULL == symbol)
if (NULL != symbol)
and through flags "--types COMPARISON_TO_NULL --fix-inplace".

The unmodified checkpatch detects this pattern as Yoda condition,
but it's odd fixing it as Yoda condition and then again as NULL
comparison. This triggered the modification to the script.

Change-Id: I5fe984a85e9c4fc799f049211797aef891ebce18
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/6352
Tested-by: jenkins
12 files changed:
src/flash/nand/arm_io.c
src/flash/nand/core.c
src/flash/nor/core.c
src/helper/binarybuffer.c
src/jtag/adapter.c
src/jtag/commands.c
src/jtag/drivers/vsllink.c
src/jtag/drivers/xds110.c
src/openocd.c
src/rtos/mqx.c
src/svf/svf.c
src/target/target.c

index 705470e77b6b3453660fbb7cfd2f0825e9860e8a..2b0c081bdf274e5d24123e82ca351441e761c49d 100644 (file)
@@ -55,7 +55,7 @@ static int arm_code_to_working_area(struct target *target,
         */
 
        /* make sure we have a working area */
-       if (NULL == *area) {
+       if (!*area) {
                retval = target_alloc_working_area(target, size, area);
                if (retval != ERROR_OK) {
                        LOG_DEBUG("%s: no %d byte buffer", __func__, (int) size);
index d60e0d071f79c95ab762cae5464d3974a0ccaadc..c1f1bc4b8b7e966679b2a8b909ce9dbf401292e9 100644 (file)
@@ -180,7 +180,7 @@ static struct nand_device *get_nand_device_by_name(const char *name)
        unsigned found = 0;
 
        struct nand_device *nand;
-       for (nand = nand_devices; NULL != nand; nand = nand->next) {
+       for (nand = nand_devices; nand; nand = nand->next) {
                if (strcmp(nand->name, name) == 0)
                        return nand;
                if (!flash_driver_name_matches(nand->controller->name, name))
index a2d7623d04644c120f214cecbe36a4f323c6b425..30d387ae0c7ea5b1a547d5e5ac23a344e05e7e52 100644 (file)
@@ -257,7 +257,7 @@ struct flash_bank *get_flash_bank_by_name_noprobe(const char *name)
        unsigned found = 0;
 
        struct flash_bank *bank;
-       for (bank = flash_banks; NULL != bank; bank = bank->next) {
+       for (bank = flash_banks; bank; bank = bank->next) {
                if (strcmp(bank->name, name) == 0)
                        return bank;
                if (!flash_driver_name_matches(bank->driver->name, name))
index 3d35702ac96ed0829b9d11b6e51f030f15c48a80..49e347b6e1df3ef4e68e2b86225901df288074c6 100644 (file)
@@ -53,7 +53,7 @@ static const char hex_digits[] = {
 
 void *buf_cpy(const void *from, void *_to, unsigned size)
 {
-       if (NULL == from || NULL == _to)
+       if (!from || !_to)
                return NULL;
 
        /* copy entire buffer */
index b8b8f5a8fa0781da346f7944faeba522cc97bd29..80d5ab048a991e752c20199cd84cbba121c37684 100644 (file)
@@ -91,7 +91,7 @@ COMMAND_HANDLER(handle_adapter_list_command)
                return ERROR_COMMAND_SYNTAX_ERROR;
 
        command_print(CMD, "The following debug adapters are available:");
-       for (unsigned i = 0; NULL != adapter_drivers[i]; i++) {
+       for (unsigned i = 0; adapter_drivers[i]; i++) {
                const char *name = adapter_drivers[i]->name;
                command_print(CMD, "%u: %s", i + 1, name);
        }
@@ -113,11 +113,11 @@ COMMAND_HANDLER(handle_adapter_driver_command)
        if (CMD_ARGC != 1 || CMD_ARGV[0][0] == '\0')
                return ERROR_COMMAND_SYNTAX_ERROR;
 
-       for (unsigned i = 0; NULL != adapter_drivers[i]; i++) {
+       for (unsigned i = 0; adapter_drivers[i]; i++) {
                if (strcmp(CMD_ARGV[0], adapter_drivers[i]->name) != 0)
                        continue;
 
-               if (NULL != adapter_drivers[i]->commands) {
+               if (adapter_drivers[i]->commands) {
                        retval = register_commands(CMD_CTX, NULL,
                                        adapter_drivers[i]->commands);
                        if (retval != ERROR_OK)
index aacedbd67513678f38fdd16e805be1bccb93ea0b..206c5e8f5290f1f2ac7b9f5b1c1327721b321c8a 100644 (file)
@@ -67,7 +67,7 @@ void jtag_queue_command(struct jtag_command *cmd)
 
        struct jtag_command **last_cmd = next_command_pointer;
        assert(last_cmd);
-       assert(NULL == *last_cmd);
+       assert(!*last_cmd);
        *last_cmd = cmd;
 
        /* store location where the next command pointer will be stored */
index b4597b788dce87d376b1e23bece146d2d5377093..6361ee0dad772b85a224ada7fc88a876b1608407 100644 (file)
@@ -785,7 +785,7 @@ static int vsllink_check_usb_strings(
        char desc_string[256];
        int retval;
 
-       if (NULL != versaloon_interface.usb_setting.serialstring) {
+       if (versaloon_interface.usb_setting.serialstring) {
                retval = libusb_get_string_descriptor_ascii(usb_device_handle,
                        usb_desc->iSerialNumber, (unsigned char *)desc_string,
                        sizeof(desc_string));
index e89cfe589d36f687da12d7a2afcb6d68c17b6f41..f62051422df52e8e7e75f75e5dc961675491d7e9 100644 (file)
@@ -472,7 +472,7 @@ static bool usb_read(unsigned char *buffer, int size, int *bytes_read,
 {
        int result;
 
-       if (NULL == xds110.dev || NULL == buffer || NULL == bytes_read)
+       if (!xds110.dev || !buffer || !bytes_read)
                return false;
 
        /* Force a non-zero timeout to prevent blocking */
@@ -491,7 +491,7 @@ static bool usb_write(unsigned char *buffer, int size, int *written)
        int result = LIBUSB_SUCCESS;
        int retries = 0;
 
-       if (NULL == xds110.dev || NULL == buffer)
+       if (!xds110.dev || !buffer)
                return false;
 
        result = libusb_bulk_transfer(xds110.dev, xds110.endpoint_out, buffer,
@@ -1037,7 +1037,7 @@ static bool ocd_dap_request(uint8_t *dap_requests, uint32_t request_size,
 
        bool success;
 
-       if (NULL == dap_requests || NULL == dap_results)
+       if (!dap_requests || !dap_results)
                return false;
 
        xds110.write_payload[0] = OCD_DAP_REQUEST;
@@ -1062,7 +1062,7 @@ static bool ocd_scan_request(uint8_t *scan_requests, uint32_t request_size,
 
        bool success;
 
-       if (NULL == scan_requests || NULL == scan_results)
+       if (!scan_requests || !scan_results)
                return false;
 
        xds110.write_payload[0] = OCD_SCAN_REQUEST;
index 2eb7346c5705b036de3329119fcefa946937d104..2c94666243d724e8961d30b4e5f6b711a1c23e13 100644 (file)
@@ -262,7 +262,7 @@ static struct command_context *setup_command_handler(Jim_Interp *interp)
                &arm_tpiu_swo_register_commands,
                NULL
        };
-       for (unsigned i = 0; NULL != command_registrants[i]; i++) {
+       for (unsigned i = 0; command_registrants[i]; i++) {
                int retval = (*command_registrants[i])(cmd_ctx);
                if (retval != ERROR_OK) {
                        command_done(cmd_ctx);
index 710436b7423b23bd3c0f270773116661b2e6dc2d..777d23ce35e19a63dd28f75a574b7f21071ee0a3 100644 (file)
@@ -393,7 +393,7 @@ static int mqx_update_threads(
                rtos->thread_details[i].exists = true;
                /* set thread name */
                rtos->thread_details[i].thread_name_str = malloc(strlen((void *)task_name) + 1);
-               if (NULL == rtos->thread_details[i].thread_name_str)
+               if (!rtos->thread_details[i].thread_name_str)
                        return ERROR_FAIL;
                strcpy(rtos->thread_details[i].thread_name_str, (void *)task_name);
                /* set thread extra info
@@ -405,7 +405,7 @@ static int mqx_update_threads(
                 */
                extra_info_length += strlen((void *)state_name) + 7 + 13 + 8 + 15 + 8;
                rtos->thread_details[i].extra_info_str = malloc(extra_info_length + 1);
-               if (NULL == rtos->thread_details[i].extra_info_str)
+               if (!rtos->thread_details[i].extra_info_str)
                        return ERROR_FAIL;
                snprintf(rtos->thread_details[i].extra_info_str, extra_info_length,
                         "State: %s, Address: 0x%" PRIx32 ",  Error Code: %" PRIu32,
@@ -501,7 +501,7 @@ static int mqx_get_thread_reg_list(
 static int mqx_get_symbol_list_to_lookup(struct symbol_table_elem *symbol_list[])
 {
        *symbol_list = calloc(ARRAY_SIZE(mqx_symbol_list), sizeof(struct symbol_table_elem));
-       if (NULL == *symbol_list)
+       if (!*symbol_list)
                return ERROR_FAIL;
        /* export required symbols */
        for (int i = 0; i < (int)(ARRAY_SIZE(mqx_symbol_list)); i++)
index 553bdc7e1a5e306df225bf3853134a225c405ca4..c93d530d2a33d80eead8281d038d3342bf8f5462 100644 (file)
@@ -761,10 +761,10 @@ static int svf_adjust_array_length(uint8_t **arr, int orig_bit_len, int new_bit_
 {
        int new_byte_len = (new_bit_len + 7) >> 3;
 
-       if ((NULL == *arr) || (((orig_bit_len + 7) >> 3) < ((new_bit_len + 7) >> 3))) {
+       if ((!*arr) || (((orig_bit_len + 7) >> 3) < ((new_bit_len + 7) >> 3))) {
                free(*arr);
                *arr = calloc(1, new_byte_len);
-               if (NULL == *arr) {
+               if (!*arr) {
                        LOG_ERROR("not enough memory");
                        return ERROR_FAIL;
                }
index 686aa5157f21af4f4331243c2bf1d17860e743d9..1879430a879119f0c01504eeedca79a90d0b7e62 100644 (file)
@@ -5937,7 +5937,7 @@ static int jim_target_types(Jim_Interp *interp, int argc, Jim_Obj *const *argv)
                return JIM_ERR;
        }
        Jim_SetResult(interp, Jim_NewListObj(interp, NULL, 0));
-       for (unsigned x = 0; NULL != target_types[x]; x++) {
+       for (unsigned x = 0; target_types[x]; x++) {
                Jim_ListAppendElement(interp, Jim_GetResult(interp),
                        Jim_NewStringObj(interp, target_types[x]->name, -1));
        }

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)