From cf95c3bd82c46339e9cf68058c62c934aabff2ec Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 29 Apr 2023 18:08:05 +0200 Subject: [PATCH] cleanup: remove unnecessary string duplication I don't understand why the functions must be called on a copy of the string. Signed-off-by: Berthold Stoeger --- core/unix.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/core/unix.c b/core/unix.c index 41d6ed09a..1adb35953 100644 --- a/core/unix.c +++ b/core/unix.c @@ -90,7 +90,6 @@ int enumerate_devices(device_callback_t callback, void *userdata, unsigned int t size_t i; FILE *file; char *line = NULL; - char *fname; size_t len; if (transport & DC_TRANSPORT_SERIAL) { const char *dirname = "/dev"; @@ -155,15 +154,13 @@ int enumerate_devices(device_callback_t callback, void *userdata, unsigned int t end++; *end = '\0'; - fname = strdup(start); - callback(fname, userdata); + callback(start, userdata); - if (is_default_dive_computer_device(fname)) + if (is_default_dive_computer_device(start)) index = entries; entries++; num_uemis++; - free((void *)fname); } } free(line);