]> sigrok.org Git - libsigrok.git/commitdiff
Don't check g_free() arguments for NULL.
authorUwe Hermann <redacted>
Fri, 27 Mar 2015 07:39:49 +0000 (08:39 +0100)
committerUwe Hermann <redacted>
Tue, 31 Mar 2015 22:23:25 +0000 (00:23 +0200)
The g_free() call is guaranteed to not segfault when NULL is passed.

src/backend.c
src/hardware/gmc-mh-1x-2x/api.c
src/hardware/hameg-hmo/api.c
src/hardware/hameg-hmo/protocol.c
src/hardware/manson-hcs-3xxx/api.c
src/hardware/motech-lps-30x/api.c
src/hardware/yokogawa-dlm/api.c
src/hardware/yokogawa-dlm/protocol_wrappers.c
src/input/csv.c

index c2a83cfedfe4f48a831696ee1b58dfe0b99a10a4..ae56f37020d93987da63f37713f01411ef354486 100644 (file)
@@ -418,8 +418,7 @@ SR_API int sr_init(struct sr_context **ctx)
        ret = SR_OK;
 
 done:
-       if (context)
-               g_free(context);
+       g_free(context);
        return ret;
 }
 
index baa75738b89d0140382970e9bcdfbe768d9d807e..8f9be220ff39dae7989176b612664275a63e6712 100644 (file)
@@ -345,8 +345,7 @@ exit_err:
 
        if (serial)
                sr_serial_dev_inst_free(serial);
-       if (devc)
-               g_free(devc);
+       g_free(devc);
        if (sdi)
                sr_dev_inst_free(sdi);
 
index 4622ab613fd69b13f88cbbe278c6c1881c05a985..cad91c75adfacc4f0059920aee54cb9ad5c45bb7 100644 (file)
@@ -109,8 +109,7 @@ fail:
                sr_scpi_hw_info_free(hw_info);
        if (sdi)
                sr_dev_inst_free(sdi);
-       if (devc)
-               g_free(devc);
+       g_free(devc);
 
        return NULL;
 }
index 77027f1d300ecedc25db9cf9381c487db86805bc..49f956c6aae685fec9568294f116663a5d05c61e 100644 (file)
@@ -690,8 +690,7 @@ SR_PRIV int hmo_receive_data(int fd, int revents, void *cb_data)
                        break;
                case SR_CHANNEL_LOGIC:
                        if (sr_scpi_get_uint8v(sdi->conn, NULL, &data) != SR_OK) {
-                               if (data)
-                                       g_free(data);
+                               g_free(data);
                                return TRUE;
                        }
 
index 8c184ca4a696c95918510f420b7da744a8f433f3..4ee06dc180f2d48ad71c2e92922284b2f7a15666 100644 (file)
@@ -197,8 +197,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options)
 
 exit_err:
        sr_dev_inst_free(sdi);
-       if (devc)
-               g_free(devc);
+       g_free(devc);
+
        return NULL;
 }
 
index ee873e8684a0b98131f4c853c758fc6935610ef4..1789e42b80fd2313b73f429aa9436606cb5af816 100644 (file)
@@ -501,8 +501,7 @@ exit_err:
                serial_close(serial);
                sr_serial_dev_inst_free(serial);
        }
-       if (devc)
-               g_free(devc);
+       g_free(devc);
        if (sdi)
                sr_dev_inst_free(sdi);
 
index fcc84e1b1814dff0bfcf134e7b4af7810698edf2..1bbab68992fa8fac96b3a7585e66d7ff70558963 100644 (file)
@@ -97,8 +97,7 @@ fail:
                sr_scpi_hw_info_free(hw_info);
        if (sdi)
                sr_dev_inst_free(sdi);
-       if (devc)
-               g_free(devc);
+       g_free(devc);
 
        return NULL;
 }
index afe4efa317b865f9251d22214e61b2468dd48c17..5f5b5bfab7478d6461b98980964f14513f571ff4 100644 (file)
@@ -92,6 +92,7 @@ int dlm_trigger_slope_get(struct sr_scpi_dev_inst *scpi,
        }
 
        g_free(resp);
+
        return result;
 }
 
index 73e911dff5c62aa3770bcbdba0a17c5ab1cd9aac..f4f11f25d18bd21287745620c3c61b93fce1cb3b 100644 (file)
@@ -777,11 +777,8 @@ static void cleanup(struct sr_input *in)
        if (inc->comment)
                g_string_free(inc->comment, TRUE);
 
-       if (inc->termination)
-               g_free(inc->termination);
-
-       if (inc->sample_buffer)
-               g_free(inc->sample_buffer);
+       g_free(inc->termination);
+       g_free(inc->sample_buffer);
 }
 
 static struct sr_option options[] = {