Changeset: 2fda4ff610b2 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=2fda4ff610b2
Modified Files:
common/utils/msabaoth.c
gdk/gdk_bat.c
gdk/gdk_bbp.c
gdk/gdk_heap.c
gdk/gdk_logger.c
gdk/gdk_posix.h
gdk/gdk_storage.c
monetdb5/modules/mal/mal_mapi.c
sql/backends/monet5/vaults/bam/bam_export.c
sql/backends/monet5/vaults/bam/bam_wrapper.c
sql/backends/monet5/vaults/vault.c
testing/difflib.c
tools/merovingian/daemon/controlrunner.c
tools/merovingian/daemon/forkmserver.c
tools/merovingian/daemon/merovingian.c
tools/merovingian/utils/database.c
tools/merovingian/utils/utils.c
Branch: default
Log Message:
Use remove from the C standard instead of unlink from the Posix standard.
diffs (truncated from 497 to 300 lines):
diff --git a/common/utils/msabaoth.c b/common/utils/msabaoth.c
--- a/common/utils/msabaoth.c
+++ b/common/utils/msabaoth.c
@@ -186,10 +186,10 @@ msab_init(const char *dbfarm, const char
}
}
closedir(d);
- /* unlink in a separate loop after reading the
directory,
+ /* remove in a separate loop after reading the
directory,
* so as to not have any interference */
while (dbe != NULL) {
- unlink(dbe->path);
+ remove(dbe->path);
db = dbe;
dbe = dbe->next;
free(db);
@@ -339,7 +339,7 @@ msab_retreatScenario(const char *lang)
return(NULL);
} else {
(void)fclose(f);
- unlink(pathbuf);
+ remove(pathbuf);
return(NULL);
}
} else {
@@ -350,7 +350,7 @@ msab_retreatScenario(const char *lang)
(void)fclose(f);
return strdup(buf);
} else
- unlink(pathbuf); /* empty file? try to remove
*/
+ remove(pathbuf); /* empty file? try to remove
*/
(void)fclose(f);
return(NULL);
}
@@ -414,19 +414,19 @@ msab_wildRetreat(void)
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), SCENARIOFILE)) != NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), CONNECTIONFILE)) != NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), STARTEDFILE)) != NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), _sabaoth_internal_uuid))
!= NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
return(NULL);
}
@@ -480,7 +480,7 @@ msab_registerStarting(void)
/* remove any stray file that would suggest we've finished starting up
*/
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), STARTEDFILE)) != NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
return(NULL);
@@ -540,7 +540,7 @@ msab_registerStop(void)
* but for the sake of keeping things clean ... */
if ((tmp = getDBPath(pathbuf, sizeof(pathbuf), _sabaoth_internal_uuid))
!= NULL)
return(tmp);
- unlink(pathbuf);
+ remove(pathbuf);
return(NULL);
}
diff --git a/gdk/gdk_bat.c b/gdk/gdk_bat.c
--- a/gdk/gdk_bat.c
+++ b/gdk/gdk_bat.c
@@ -1706,9 +1706,9 @@ backup_new(Heap *hp, int lockbat)
IODEBUG fprintf(stderr, "#rename(%s,%s) = %d\n", batpath,
bakpath, ret);
} else if (batret == 0) {
/* there is a backup already; just remove the X.new */
- if ((ret = unlink(batpath)) < 0)
- GDKsyserror("backup_new: unlink %s failed\n", batpath);
- IODEBUG fprintf(stderr, "#unlink(%s) = %d\n", batpath, ret);
+ if ((ret = remove(batpath)) != 0)
+ GDKsyserror("backup_new: remove %s failed\n", batpath);
+ IODEBUG fprintf(stderr, "#remove(%s) = %d\n", batpath, ret);
}
GDKfree(batpath);
GDKfree(bakpath);
diff --git a/gdk/gdk_bbp.c b/gdk/gdk_bbp.c
--- a/gdk/gdk_bbp.c
+++ b/gdk/gdk_bbp.c
@@ -3600,10 +3600,10 @@ force_move(int farmid, const char *srcdi
/* step 1: remove the X.new file that is going to be
* overridden by X */
- if (unlink(dstpath) < 0 && errno != ENOENT) {
+ if (remove(dstpath) != 0 && errno != ENOENT) {
/* if it exists and cannot be removed, all
* this is going to fail */
- GDKsyserror("force_move: unlink(%s)\n", dstpath);
+ GDKsyserror("force_move: remove(%s)\n", dstpath);
GDKfree(dstpath);
return GDK_FAIL;
}
@@ -3612,9 +3612,9 @@ force_move(int farmid, const char *srcdi
/* step 2: now remove the .kill file. This one is
* crucial, otherwise we'll never finish recovering */
killfile = GDKfilepath(farmid, srcdir, name, NULL);
- if (unlink(killfile) < 0) {
+ if (remove(killfile) != 0) {
ret = GDK_FAIL;
- GDKsyserror("force_move: unlink(%s)\n", killfile);
+ GDKsyserror("force_move: remove(%s)\n", killfile);
}
GDKfree(killfile);
return ret;
@@ -3629,9 +3629,9 @@ force_move(int farmid, const char *srcdi
* doesn't exist */
dstpath = GDKfilepath(farmid, dstdir, name, NULL);
srcpath = GDKfilepath(farmid, srcdir, name, NULL);
- if (unlink(dstpath) < 0) /* clear destination */
+ if (remove(dstpath) != 0) /* clear destination */
ret = GDK_FAIL;
- IODEBUG fprintf(stderr, "#unlink %s = %d\n", dstpath, (int)
ret);
+ IODEBUG fprintf(stderr, "#remove %s = %d\n", dstpath, (int)
ret);
(void) GDKcreatedir(dstdir); /* if fails, move will fail */
ret = GDKmove(farmid, srcdir, name, NULL, dstdir, name, NULL);
@@ -3695,8 +3695,8 @@ BBPrecover(int farmid)
continue;
fn = GDKfilepath(farmid, BAKDIR, dent->d_name, NULL);
if (fn) {
- int uret = unlink(fn);
- IODEBUG fprintf(stderr, "#unlink %s = %d\n",
+ int uret = remove(fn);
+ IODEBUG fprintf(stderr, "#remove %s = %d\n",
fn, uret);
GDKfree(fn);
}
@@ -3955,11 +3955,11 @@ BBPdiskscan(const char *parent, size_t b
break;
}
if (delete) {
- if (unlink(fullname) < 0 && errno != ENOENT) {
- GDKsyserror("BBPdiskscan: unlink(%s)",
fullname);
+ if (remove(fullname) != 0 && errno != ENOENT) {
+ GDKsyserror("BBPdiskscan: remove(%s)",
fullname);
continue;
}
- IODEBUG fprintf(stderr, "#BBPcleanup: unlink(%s) =
0\n", fullname);
+ IODEBUG fprintf(stderr, "#BBPcleanup: remove(%s) =
0\n", fullname);
}
}
closedir(dirp);
diff --git a/gdk/gdk_heap.c b/gdk/gdk_heap.c
--- a/gdk/gdk_heap.c
+++ b/gdk/gdk_heap.c
@@ -564,9 +564,9 @@ HEAPcopy(Heap *dst, Heap *src)
}
/* Free the memory associated with the heap H.
- * Unlinks (removes) the associated file if the remove flag is set. */
+ * Unlinks (removes) the associated file if the rmheap flag is set. */
void
-HEAPfree(Heap *h, int remove)
+HEAPfree(Heap *h, int rmheap)
{
if (h->base) {
if (h->storage == STORE_MEM) { /* plain memory */
@@ -594,7 +594,7 @@ HEAPfree(Heap *h, int remove)
#ifdef HAVE_FORK
if (h->storage == STORE_MMAPABS) {
// heap is stored in a mmap() file, but h->filename points to
the absolute path
- if (h->filename && unlink(h->filename) < 0 && errno != ENOENT) {
+ if (h->filename && remove(h->filename) != 0 && errno != ENOENT)
{
perror(h->filename);
}
GDKfree(h->filename);
@@ -603,13 +603,13 @@ HEAPfree(Heap *h, int remove)
#endif
h->base = NULL;
if (h->filename) {
- if (remove) {
+ if (rmheap) {
char *path = GDKfilepath(h->farmid, BATDIR,
h->filename, NULL);
- if (path && unlink(path) < 0 && errno != ENOENT)
+ if (path && remove(path) != 0 && errno != ENOENT)
perror(path);
GDKfree(path);
path = GDKfilepath(h->farmid, BATDIR, h->filename,
"new");
- if (path && unlink(path) < 0 && errno != ENOENT)
+ if (path && remove(path) != 0 && errno != ENOENT)
perror(path);
GDKfree(path);
}
diff --git a/gdk/gdk_logger.c b/gdk/gdk_logger.c
--- a/gdk/gdk_logger.c
+++ b/gdk/gdk_logger.c
@@ -1564,7 +1564,7 @@ logger_load(int debug, const char *fn, c
lg->id ++;
if (fprintf(fp, "%06d\n\n" LLFMT "\n", lg->version, lg->id) <
0) {
fclose(fp);
- unlink(filename);
+ remove(filename);
GDKerror("logger_load: writing log file %s failed",
filename);
goto error;
@@ -1578,7 +1578,7 @@ logger_load(int debug, const char *fn, c
fsync(fileno(fp)) < 0 ||
#endif
fclose(fp) < 0) {
- unlink(filename);
+ remove(filename);
GDKerror("logger_load: closing log file %s failed",
filename);
goto error;
@@ -1591,7 +1591,7 @@ logger_load(int debug, const char *fn, c
if (bm_subcommit(lg, lg->catalog_bid, lg->catalog_nme,
lg->catalog_bid, lg->catalog_nme, lg->dcatalog, NULL, lg->debug) !=
GDK_SUCCEED) {
/* cannot commit catalog, so remove log */
- unlink(filename);
+ remove(filename);
BBPrelease(lg->catalog_bid->batCacheid);
BBPrelease(lg->catalog_nme->batCacheid);
BBPrelease(lg->dcatalog->batCacheid);
@@ -2281,9 +2281,9 @@ logger_unlink(int farmid, const char *di
path = GDKfilepath(farmid, dir, nme, ext);
if (path == NULL)
return GDK_FAIL;
- u = unlink(path);
+ u = remove(path);
GDKfree(path);
- return u < 0 ? GDK_FAIL : GDK_SUCCEED;
+ return u != 0 ? GDK_FAIL : GDK_SUCCEED;
}
static void
diff --git a/gdk/gdk_posix.h b/gdk/gdk_posix.h
--- a/gdk/gdk_posix.h
+++ b/gdk/gdk_posix.h
@@ -192,7 +192,7 @@ gdk_export int win_mkdir(const char *, c
#define mkdir win_mkdir
#define rmdir win_rmdir
#define rename win_rename
-#define unlink win_unlink
+#define remove win_unlink
#endif /* NATIVE_WIN32 */
diff --git a/gdk/gdk_storage.c b/gdk/gdk_storage.c
--- a/gdk/gdk_storage.c
+++ b/gdk/gdk_storage.c
@@ -161,13 +161,13 @@ GDKremovedir(int farmid, const char *dir
continue;
}
path = GDKfilepath(farmid, dirname, dent->d_name, NULL);
- ret = unlink(path);
- IODEBUG fprintf(stderr, "#unlink %s = %d\n", path, ret);
+ ret = remove(path);
+ IODEBUG fprintf(stderr, "#remove %s = %d\n", path, ret);
GDKfree(path);
}
closedir(dirp);
ret = rmdir(dirnamestr);
- if (ret < 0)
+ if (ret != 0)
GDKsyserror("GDKremovedir: rmdir(%s) failed.\n", dirnamestr);
IODEBUG fprintf(stderr, "#rmdir %s = %d\n", dirnamestr, ret);
GDKfree(dirnamestr);
@@ -263,7 +263,7 @@ GDKfileopen(int farmid, const char * dir
return NULL;
}
-/* unlink the file */
+/* remove the file */
gdk_return
GDKunlink(int farmid, const char *dir, const char *nme, const char *ext)
{
@@ -272,9 +272,9 @@ GDKunlink(int farmid, const char *dir, c
path = GDKfilepath(farmid, dir, nme, ext);
/* if file already doesn't exist, we don't care */
- if (unlink(path) == -1 && errno != ENOENT) {
+ if (remove(path) != 0 && errno != ENOENT) {
GDKsyserror("GDKunlink(%s)\n", path);
- IODEBUG fprintf(stderr, "#unlink %s = -1\n", path);
+ IODEBUG fprintf(stderr, "#remove %s = -1\n", path);
GDKfree(path);
return GDK_FAIL;
}
diff --git a/monetdb5/modules/mal/mal_mapi.c b/monetdb5/modules/mal/mal_mapi.c
--- a/monetdb5/modules/mal/mal_mapi.c
+++ b/monetdb5/modules/mal/mal_mapi.c
@@ -734,11 +734,11 @@ SERVERlisten(int *Port, str *Usockfile,
userver.sun_path[sizeof(userver.sun_path) - 1] = 0;
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list