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 <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2023-04-29 18:08:05 +02:00 committed by bstoeger
parent 15bf145f14
commit cf95c3bd82

View file

@ -90,7 +90,6 @@ int enumerate_devices(device_callback_t callback, void *userdata, unsigned int t
size_t i; size_t i;
FILE *file; FILE *file;
char *line = NULL; char *line = NULL;
char *fname;
size_t len; size_t len;
if (transport & DC_TRANSPORT_SERIAL) { if (transport & DC_TRANSPORT_SERIAL) {
const char *dirname = "/dev"; const char *dirname = "/dev";
@ -155,15 +154,13 @@ int enumerate_devices(device_callback_t callback, void *userdata, unsigned int t
end++; end++;
*end = '\0'; *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; index = entries;
entries++; entries++;
num_uemis++; num_uemis++;
free((void *)fname);
} }
} }
free(line); free(line);