openocd: fix simple cases of NULL comparison
[fw/openocd] / src / jtag / drivers / cmsis_dap_usb_bulk.c
index c42bab28f5301559e193cdf0d86a273f87fbac10..cb3e02fe2be9c9c7d818d07e6e9413503dc82a98 100644 (file)
@@ -353,7 +353,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
                                LOG_WARNING("could not claim interface: %s", libusb_strerror(err));
 
                        dap->bdata = malloc(sizeof(struct cmsis_dap_backend_data));
-                       if (dap->bdata == NULL) {
+                       if (!dap->bdata) {
                                LOG_ERROR("unable to allocate memory");
                                libusb_release_interface(dev_handle, interface_num);
                                libusb_close(dev_handle);
@@ -370,7 +370,7 @@ static int cmsis_dap_usb_open(struct cmsis_dap *dap, uint16_t vids[], uint16_t p
                        dap->bdata->interface = interface_num;
 
                        dap->packet_buffer = malloc(dap->packet_buffer_size);
-                       if (dap->packet_buffer == NULL) {
+                       if (!dap->packet_buffer) {
                                LOG_ERROR("unable to allocate memory");
                                cmsis_dap_usb_close(dap);
                                return ERROR_FAIL;
@@ -446,7 +446,7 @@ static int cmsis_dap_usb_write(struct cmsis_dap *dap, int txlen, int timeout_ms)
 static int cmsis_dap_usb_alloc(struct cmsis_dap *dap, unsigned int pkt_sz)
 {
        uint8_t *buf = malloc(pkt_sz);
-       if (buf == NULL) {
+       if (!buf) {
                LOG_ERROR("unable to allocate CMSIS-DAP packet buffer");
                return ERROR_FAIL;
        }