char *retpath = NULL;
int len, rem;
- dir = opendir(ap->devpath);
- if (!dir)
- return NULL;
-
len = strlen(ap->devpath);
rem = DEVNAME_MAX-2 - len;
if (rem <= 0)
return NULL;
+
+ dir = opendir(ap->devpath);
+ if (!dir)
+ return NULL;
+
ap->devpath[len++] = '/';
while ((entry = readdir(dir)) != NULL) {