From: Guido Draheim Date: Tue, 25 Apr 2017 19:37:21 +0000 (+0200) Subject: cleanup debug()->DBG() X-Git-Tag: v0.13.67~15 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=c4dbcef3cb18921fe0ff4815b5d19bf913fcf0d0;p=zziplib cleanup debug()->DBG() --- diff --git a/bins/unzzipcat-big.c b/bins/unzzipcat-big.c index d2df75b..c2453fb 100644 --- a/bins/unzzipcat-big.c +++ b/bins/unzzipcat-big.c @@ -9,6 +9,7 @@ #include #include #include +#include #include "unzzipcat-zip.h" #ifdef ZZIP_HAVE_FNMATCH_H @@ -21,16 +22,6 @@ #define O_BINARY 0 #endif -#ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#else -#define debug1(msg) -#define debug2(msg, arg1) -#define debug3(msg, arg1, arg2) -#endif - static void unzzip_big_entry_fprint(ZZIP_ENTRY* entry, FILE* out) { ZZIP_ENTRY_FILE* file = zzip_entry_fopen (entry, 0); @@ -39,14 +30,14 @@ static void unzzip_big_entry_fprint(ZZIP_ENTRY* entry, FILE* out) char buffer[1024]; int len; while ((len = zzip_entry_fread (buffer, 1024, 1, file))) { - debug2("entry read %i", len); + DBG2("entry read %i", len); fwrite (buffer, len, 1, out); } - debug2("entry done %s", strerror(errno)); + DBG2("entry done %s", strerror(errno)); zzip_entry_fclose (file); } else { - debug2("could not open entry: %s", strerror(errno)); + DBG2("could not open entry: %s", strerror(errno)); } } @@ -133,7 +124,7 @@ static int unzzip_cat (int argc, char ** argv, int extract) for (; entry ; entry = zzip_entry_findnext(entry)) { char* name = zzip_entry_strdup_name (entry); - debug3(".. check '%s' to zip '%s'", argv[argn], name); + DBG3(".. check '%s' to zip '%s'", argv[argn], name); if (! fnmatch (argv[argn], name, FNM_NOESCAPE|FNM_PATHNAME|FNM_PERIOD)) { diff --git a/bins/unzzipdir-big.c b/bins/unzzipdir-big.c index e2a4c59..d69bbf9 100644 --- a/bins/unzzipdir-big.c +++ b/bins/unzzipdir-big.c @@ -23,16 +23,6 @@ #define O_BINARY 0 #endif -#ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#else -#define debug1(msg) -#define debug2(msg, arg1) -#define debug3(msg, arg1, arg2) -#endif - static const char* comprlevel[] = { "stored", "shrunk", "redu:1", "redu:2", "redu:3", "redu:4", "impl:N", "toknze", "defl:N", "defl:B", "impl:B" }; diff --git a/zzip/mmapped.c b/zzip/mmapped.c index 67f293f..87d76a1 100644 --- a/zzip/mmapped.c +++ b/zzip/mmapped.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include @@ -57,18 +58,6 @@ #define ____ } #endif -#ifdef DEBUG -#define debug1(msg) do { fprintf(stderr, "%s : " msg "\n", __func__); } while(0) -#define debug2(msg, arg1) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1); } while(0) -#define debug3(msg, arg1, arg2) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2); } while(0) -#define debug4(msg, arg1, arg2, arg3) do { fprintf(stderr, "%s : " msg "\n", __func__, arg1, arg2, arg3); } while(0) -#else -#define debug1(msg) -#define debug2(msg, arg1) -#define debug3(msg, arg1, arg2) -#define debug4(msg, arg1, arg2, arg3) -#endif - /** => zzip_disk_mmap * This function does primary initialization of a disk-buffer struct. * @@ -453,16 +442,16 @@ zzip_disk_entry_strdup_comment(ZZIP_DISK * disk, struct zzip_disk_entry *entry) struct zzip_disk_entry * zzip_disk_findfirst(ZZIP_DISK * disk) { - debug1("findfirst"); + DBG1("findfirst"); if (! disk) { - debug1("non arg"); + DBG1("non arg"); errno = EINVAL; return 0; } if (disk->buffer > disk->endbuf - sizeof(struct zzip_disk_trailer)) { - debug1("not enough data for a disk trailer"); + DBG1("not enough data for a disk trailer"); errno = EBADMSG; return 0; } @@ -475,12 +464,12 @@ zzip_disk_findfirst(ZZIP_DISK * disk) struct zzip_disk_trailer *trailer = (struct zzip_disk_trailer *) p; zzip_size_t rootseek = zzip_disk_trailer_get_rootseek(trailer); root = disk->buffer + rootseek; - debug2("disk rootseek at %lli", (long long)rootseek); + DBG2("disk rootseek at %lli", (long long)rootseek); if (root > p) { /* the first disk_entry is after the disk_trailer? can't be! */ zzip_size_t rootsize = zzip_disk_trailer_get_rootsize(trailer); - debug2("have rootsize at %lli", (long long)rootsize); + DBG2("have rootsize at %lli", (long long)rootsize); if (disk->buffer + rootsize > p) continue; /* a common brokeness that can be fixed: we just assume the @@ -493,12 +482,12 @@ zzip_disk_findfirst(ZZIP_DISK * disk) (struct zzip_disk64_trailer *) p; if (sizeof(void *) < 8) { - debug1("disk64 trailer in non-largefile part"); + DBG1("disk64 trailer in non-largefile part"); errno = EFBIG; return 0; } zzip_size_t rootseek = zzip_disk64_trailer_get_rootseek(trailer); - debug2("disk64 rootseek at %lli", (long long)rootseek); + DBG2("disk64 rootseek at %lli", (long long)rootseek); root = disk->buffer + rootseek; if (root > p) continue; @@ -507,16 +496,16 @@ zzip_disk_findfirst(ZZIP_DISK * disk) continue; } - debug4("buffer %p root %p endbuf %p", disk->buffer, root, disk->endbuf); + DBG4("buffer %p root %p endbuf %p", disk->buffer, root, disk->endbuf); if (root < disk->buffer) { - debug1("root before buffer should be impossible"); + DBG1("root before buffer should be impossible"); errno = EBADMSG; return 0; } if (zzip_disk_entry_check_magic(root)) { - debug1("found the disk root"); + DBG1("found the disk root"); return (struct zzip_disk_entry *) root; } } ____;