Code

sigrok plugin: malloc + memset -> calloc
authorRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:16:28 +0000 (18:16 +0200)
committerRuben Kerkhof <ruben@rubenkerkhof.com>
Fri, 1 Apr 2016 16:16:28 +0000 (18:16 +0200)
src/sigrok.c

index 4e61f946f0230874074a222986e494b16fc1dd9d..6c781f81c50a56597be7cfa376a776158dcd687a 100644 (file)
@@ -72,11 +72,10 @@ static int sigrok_config_device(oconfig_item_t *ci)
        struct config_device *cfdev;
        int i;
 
-       if (!(cfdev = malloc(sizeof(*cfdev)))) {
-               ERROR("sigrok plugin: malloc() failed.");
+       if (!(cfdev = calloc(1, sizeof(*cfdev)))) {
+               ERROR("sigrok plugin: calloc failed.");
                return -1;
        }
-       memset(cfdev, 0, sizeof(*cfdev));
        if (cf_util_get_string(ci, &cfdev->name)) {
                free(cfdev);
                WARNING("sigrok plugin: Invalid device name.");