Code

Merge branch 'master' of git://git.tokkee.org/sysdb
authorSebastian Harl <sh@tokkee.org>
Sun, 25 Sep 2016 18:54:24 +0000 (20:54 +0200)
committerSebastian Harl <sh@tokkee.org>
Sun, 25 Sep 2016 18:54:24 +0000 (20:54 +0200)
src/utils/os.c
t/unit/utils/dbi_test.c

index 8ab52c75bc023c2bc5b68ca61d2cc0f13ce0f916..70142f7ba8d6ab093bf907e38e47cc8e8ae30159 100644 (file)
@@ -172,26 +172,25 @@ sdb_remove_all(const char *pathname)
                        return -1;
 
                while (42) {
-                       struct dirent de;
-                       struct dirent *res = NULL;
+                       struct dirent *de;
+                       char filename[strlen(pathname) + sizeof(de->d_name) + 2];
 
-                       char filename[strlen(pathname) + sizeof(de.d_name) + 2];
+                       errno = 0;
+                       de = readdir(d);
+                       if (! de) {
+                               if (errno == 0)
+                                       break;
 
-                       memset(&de, 0, sizeof(de));
-                       if (readdir_r(d, &de, &res)) {
                                closedir(d);
                                return -1;
                        }
 
-                       if (! res)
-                               break;
-
-                       if ((de.d_name[0] == '.') && ((de.d_name[1] == '\0')
-                                               || ((de.d_name[1] == '.')&& (de.d_name[2] == '\0'))))
+                       if ((de->d_name[0] == '.') && ((de->d_name[1] == '\0')
+                                               || ((de->d_name[1] == '.')&& (de->d_name[2] == '\0'))))
                                continue;
 
                        snprintf(filename, sizeof(filename),
-                                       "%s/%s", pathname, de.d_name);
+                                       "%s/%s", pathname, de->d_name);
                        if (sdb_remove_all(filename)) {
                                closedir(d);
                                return -1;
index ebc34f628384e48e8cff5557f158eff41e789438..6fb2938e75f1b64319d268cd1a904ae7a902bc80 100644 (file)
@@ -164,7 +164,8 @@ const dbi_inst INST = (void *)0x4711;
 int
 dbi_initialize_r(const char __attribute__((unused)) *driverdir, dbi_inst *pInst)
 {
-       *pInst = INST;
+       if (pInst)
+               *pInst = INST;
        return 0;
 } /* dbi_initialize_r */
 
@@ -214,19 +215,19 @@ dbi_shutdown(void);
 void
 dbi_shutdown(void)
 {
-       dbi_shutdown_r(NULL);
+       dbi_shutdown_r(INST);
 } /* dbi_shutdown */
 
 dbi_driver
 dbi_driver_open(const char *name)
 {
-       return dbi_driver_open_r(name, NULL);
+       return dbi_driver_open_r(name, INST);
 } /* dbi_driver_open */
 
 dbi_driver
 dbi_driver_list(dbi_driver curr)
 {
-       return dbi_driver_list_r(curr, NULL);
+       return dbi_driver_list_r(curr, INST);
 } /* dbi_driver_list */
 #endif