openocd: fix simple cases of NULL comparison
[openocd.git] / src / jtag / drivers / linuxgpiod.c
index 99422a1168313811b448dcbdd2c98f41a10d8d55..03afd3da75a913800eea8e1dd5344efc01670f83 100644 (file)
@@ -207,14 +207,14 @@ static int linuxgpiod_reset(int trst, int srst)
        LOG_DEBUG("linuxgpiod_reset");
 
        /* assume active low */
-       if (gpiod_srst != NULL) {
+       if (gpiod_srst) {
                retval1 = gpiod_line_set_value(gpiod_srst, srst ? 0 : 1);
                if (retval1 < 0)
                        LOG_WARNING("set srst value failed");
        }
 
        /* assume active low */
-       if (gpiod_trst != NULL) {
+       if (gpiod_trst) {
                retval2 = gpiod_line_set_value(gpiod_trst, trst ? 0 : 1);
                if (retval2 < 0)
                        LOG_WARNING("set trst value failed");
@@ -284,7 +284,7 @@ static struct gpiod_line *helper_get_input_line(const char *label, unsigned int
        int retval;
 
        line = gpiod_chip_get_line(gpiod_chip, offset);
-       if (line == NULL) {
+       if (!line) {
                LOG_ERROR("Error get line %s", label);
                return NULL;
        }
@@ -304,7 +304,7 @@ static struct gpiod_line *helper_get_output_line(const char *label, unsigned int
        int retval;
 
        line = gpiod_chip_get_line(gpiod_chip, offset);
-       if (line == NULL) {
+       if (!line) {
                LOG_ERROR("Error get line %s", label);
                return NULL;
        }
@@ -325,7 +325,7 @@ static int linuxgpiod_init(void)
        bitbang_interface = &linuxgpiod_bitbang;
 
        gpiod_chip = gpiod_chip_open_by_number(gpiochip);
-       if (gpiod_chip == NULL) {
+       if (!gpiod_chip) {
                LOG_ERROR("Cannot open LinuxGPIOD gpiochip %d", gpiochip);
                return ERROR_JTAG_INIT_FAILED;
        }
@@ -343,24 +343,24 @@ static int linuxgpiod_init(void)
                }
 
                gpiod_tdo = helper_get_input_line("tdo", tdo_gpio);
-               if (gpiod_tdo == NULL)
+               if (!gpiod_tdo)
                        goto out_error;
 
                gpiod_tdi = helper_get_output_line("tdi", tdi_gpio, 0);
-               if (gpiod_tdi == NULL)
+               if (!gpiod_tdi)
                        goto out_error;
 
                gpiod_tck = helper_get_output_line("tck", tck_gpio, 0);
-               if (gpiod_tck == NULL)
+               if (!gpiod_tck)
                        goto out_error;
 
                gpiod_tms = helper_get_output_line("tms", tms_gpio, 1);
-               if (gpiod_tms == NULL)
+               if (!gpiod_tms)
                        goto out_error;
 
                if (is_gpio_valid(trst_gpio)) {
                        gpiod_trst = helper_get_output_line("trst", trst_gpio, 1);
-                       if (gpiod_trst == NULL)
+                       if (!gpiod_trst)
                                goto out_error;
                }
        }
@@ -372,23 +372,23 @@ static int linuxgpiod_init(void)
                }
 
                gpiod_swclk = helper_get_output_line("swclk", swclk_gpio, 1);
-               if (gpiod_swclk == NULL)
+               if (!gpiod_swclk)
                        goto out_error;
 
                gpiod_swdio = helper_get_output_line("swdio", swdio_gpio, 1);
-               if (gpiod_swdio == NULL)
+               if (!gpiod_swdio)
                        goto out_error;
        }
 
        if (is_gpio_valid(srst_gpio)) {
                gpiod_srst = helper_get_output_line("srst", srst_gpio, 1);
-               if (gpiod_srst == NULL)
+               if (!gpiod_srst)
                        goto out_error;
        }
 
        if (is_gpio_valid(led_gpio)) {
                gpiod_led = helper_get_output_line("led", led_gpio, 0);
-               if (gpiod_led == NULL)
+               if (!gpiod_led)
                        goto out_error;
        }
 

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)