]> xenbits.xensource.com Git - people/royger/freebsd.git/commitdiff
Cut to the chase and just call free instead of free(x) + x = NULL
authorngie <ngie@FreeBSD.org>
Sat, 10 Dec 2016 23:58:14 +0000 (23:58 +0000)
committerngie <ngie@FreeBSD.org>
Sat, 10 Dec 2016 23:58:14 +0000 (23:58 +0000)
NULLing out x wasn't required as the memory was immediately scribbled
over with strdup in the following call.

MFC after: 1 week
Submitted by: imp

sbin/camcontrol/timestamp.c

index 5f3adfe8b9b70c4cc69a6b1752f3f55d20f0a87b..032357be832138bbe52038570dddfe13fb2a5ec1 100644 (file)
@@ -336,11 +336,6 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt,
        int single_arg = 0;
        int do_utc = 0;
 
-#define        FREE(x) do {    \
-       free(x);        \
-       x = NULL;       \
-} while(0)
-
        while ((c = getopt(argc, argv, combinedopt)) != -1) {
                switch (c) {
                case 'r': {
@@ -363,7 +358,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt,
                }
                case 'f': {
                        single_arg++;
-                       FREE(format_string);
+                       free(format_string);
                        format_string = strdup(optarg);
                        if (format_string == NULL) {
                                warn("Error allocating memory for format "
@@ -375,7 +370,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt,
                }
                case 'm': {
                        single_arg++;
-                       FREE(format_string);
+                       free(format_string);
                        format_string = strdup(MIL);
                        if (format_string == NULL) {
                                warn("Error allocating memory");
@@ -389,7 +384,7 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt,
                        break;
                }
                case 'T':
-                       FREE(timestamp_string);
+                       free(timestamp_string);
                        timestamp_string = strdup(optarg);
                        if (timestamp_string == NULL) {
                                warn("Error allocating memory for format "
@@ -403,8 +398,6 @@ timestamp(struct cam_device *device, int argc, char **argv, char *combinedopt,
                }
        }
 
-#undef FREE
-
        if (action == -1) {
                warnx("Must specify an action, either -r or -s");
                error = 1;