Skip to content

Commit eb11aef

Browse files
refactor(driver): remove unneeded dup platform code (estkme-group#372)
1 parent fcd6a99 commit eb11aef

1 file changed

Lines changed: 3 additions & 20 deletions

File tree

driver/driver.c

Lines changed: 3 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -295,11 +295,11 @@ static const struct euicc_driver *find_driver_by_path(const char *restrict dir,
295295
return driver;
296296
}
297297

298-
#if defined(__unix__) || defined(__unix)
299298
static bool init_driver_list() {
300299
if (list_empty(&drivers)) {
301300
return true;
302301
}
302+
303303
_cleanup_free_ char *LPAC_DRIVER_HOME = get_driver_path();
304304
if (LPAC_DRIVER_HOME == NULL)
305305
return false;
@@ -310,8 +310,7 @@ static bool init_driver_list() {
310310

311311
struct dirent *entry;
312312
while ((entry = readdir(driver_dir)) != NULL) {
313-
if ((entry->d_type & (DT_LNK | DT_REG | DT_UNKNOWN)) && !strncmp(entry->d_name, "driver_", 7)
314-
&& ends_with(entry->d_name, dynlib_suffix)) {
313+
if (!strncmp(entry->d_name, "driver_", 7) && ends_with(entry->d_name, dynlib_suffix)) {
315314
const struct euicc_driver *driver = find_driver_by_path(LPAC_DRIVER_HOME, entry->d_name);
316315
struct euicc_drivers_list *tmp = (struct euicc_drivers_list *)calloc(1, sizeof(struct euicc_drivers_list));
317316
if (tmp == NULL) {
@@ -322,7 +321,7 @@ static bool init_driver_list() {
322321
}
323322
}
324323

325-
for (int i = 0; builtin_drivers[i] != NULL; i++) {
324+
for (size_t i = 0; builtin_drivers[i] != NULL; i++) {
326325
struct euicc_drivers_list *tmp = (struct euicc_drivers_list *)calloc(1, sizeof(struct euicc_drivers_list));
327326
if (tmp == NULL) {
328327
return false;
@@ -332,22 +331,6 @@ static bool init_driver_list() {
332331
}
333332
return true;
334333
}
335-
#else
336-
static bool init_driver_list() {
337-
if (list_empty(&drivers)) {
338-
return true;
339-
}
340-
for (int i = 0; builtin_drivers[i] != NULL; i++) {
341-
struct euicc_drivers_list *tmp = (struct euicc_drivers_list *)calloc(1, sizeof(struct euicc_drivers_list));
342-
if (tmp == NULL) {
343-
return false;
344-
}
345-
tmp->driver = builtin_drivers[i];
346-
list_add_tail(&tmp->list, &drivers);
347-
}
348-
return true;
349-
}
350-
#endif
351334

352335
static const struct euicc_driver *find_driver_by_name(const enum euicc_driver_type type, const char *name) {
353336
char *driver_type = NULL;

0 commit comments

Comments
 (0)