RPM Package Manager, CVS Repository http://rpm5.org/cvs/ ____________________________________________________________________________
Server: rpm5.org Name: Jeff Johnson Root: /v/rpm/cvs Email: [email protected] Module: rpm Date: 14-Jul-2017 13:23:14 Branch: rpm-5_4 Handle: 2017071411231300 Modified files: (Branch: rpm-5_4) rpm/rpmio rpmdav.c rpmdir.c rpmrpc.c Log: - use macro __VA_ARGS__. Summary: Revision Changes Path 2.119.2.25 +60 -60 rpm/rpmio/rpmdav.c 2.12.2.15 +10 -14 rpm/rpmio/rpmdir.c 2.99.2.15 +51 -76 rpm/rpmio/rpmrpc.c ____________________________________________________________________________ patch -p0 <<'@@ .' Index: rpm/rpmio/rpmdav.c ============================================================================ $ cvs diff -u -r2.119.2.24 -r2.119.2.25 rpmdav.c --- rpm/rpmio/rpmdav.c 26 May 2017 20:49:23 -0000 2.119.2.24 +++ rpm/rpmio/rpmdav.c 14 Jul 2017 11:23:13 -0000 2.119.2.25 @@ -58,19 +58,19 @@ #include "debug.h" -#define DAVDEBUG(_f, _list) \ +#define DAVDEBUG(_f, _fmt, ...) \ if (((_f) < 0 && _dav_debug < 0) || ((_f) > 0 && _dav_debug)) \ - fprintf _list + fprintf(stderr, _fmt, __VA_ARGS__) int _dav_hook_debug; -#define HOOKDEBUG(_f, _list) \ +#define HOOKDEBUG(_f, _fmt, ...) \ if (((_f) < 0 && _dav_hook_debug < 0) || ((_f) > 0 && _dav_hook_debug)) \ - fprintf _list + fprintf(stderr, _fmt, __VA_ARGS__) int _dav_cb_debug; -#define CALLBACKDEBUG(_f, _list) \ +#define CALLBACKDEBUG(_f, _fmt, ...) \ if (((_f) < 0 && _dav_cb_debug < 0) || ((_f) > 0 && _dav_cb_debug)) \ - fprintf _list + fprintf(stderr, _fmt, __VA_ARGS__) /* HACK: reasonable value needed (wget uses 900 as default). */ #if 0 @@ -113,7 +113,7 @@ #endif URLSANE(u); -CALLBACKDEBUG(-1, (stderr, "*** fd %p %s: %s\n", ctrl, tag, value)); +CALLBACKDEBUG(-1, "*** fd %p %s: %s\n", ctrl, tag, value); return ctrl; } @@ -133,7 +133,7 @@ #endif URLSANE(u); -CALLBACKDEBUG(-1, (stderr, "*** u %p %s: %s\n", u, tag, value)); +CALLBACKDEBUG(-1, "*** u %p %s: %s\n", u, tag, value); return u; } @@ -321,7 +321,7 @@ { FD_t ctrl = ud2fd(userdata, value, __FUNCTION__); -DAVDEBUG(1, (stderr, "<- %s\n", value)); +DAVDEBUG(1, "<- %s\n", value); } #endif @@ -392,7 +392,7 @@ #endif #endif /* NOTYET */ } -DAVDEBUG(-1, (stderr, "<-- %s(%p) active %d\n", __FUNCTION__, u, rc)); +DAVDEBUG(-1, "<-- %s(%p) active %d\n", __FUNCTION__, u, rc); rc = 0; /* XXX return active state? */ return rc; } @@ -413,7 +413,7 @@ #endif /* WITH_OPENSSL */ } #endif /* NE_FEATURE_SSL */ -DAVDEBUG(-1, (stderr, "<-- %s()\n", __FUNCTION__)); +DAVDEBUG(-1, "<-- %s()\n", __FUNCTION__); } static void davNotify(void * userdata, @@ -473,7 +473,7 @@ /* HACK: davConnect() -> ne_options2() needs fd registered in req. */ -HOOKDEBUG(-1, (stderr, "<-- %s(%p,%p,%s,%s) sess %p u %p fd %p\n", __FUNCTION__, req, userdata, method, uri, sess, u, fd)); +HOOKDEBUG(-1, "<-- %s(%p,%p,%s,%s) sess %p u %p fd %p\n", __FUNCTION__, req, userdata, method, uri, sess, u, fd); } static void davPreSend(ne_request * req, void * userdata, ne_buffer * buf) @@ -484,8 +484,8 @@ // cppcheck-suppress incorrectLogicOperator assert(fd == NULL || fd != NULL); /* Hack: fd == NULL for OPTIONS */ -DAVDEBUG(1, (stderr, "-> %s\n", buf->data)); /* XXX for wget debugging */ -HOOKDEBUG(-1, (stderr, "<-- %s(%p,%p,%p) sess %p fd %p\n", __FUNCTION__, req, userdata, buf, sess, fd)); +DAVDEBUG(1, "-> %s\n", buf->data); /* XXX for wget debugging */ +HOOKDEBUG(-1, "<-- %s(%p,%p,%p) sess %p fd %p\n", __FUNCTION__, req, userdata, buf, sess, fd); } @@ -497,7 +497,7 @@ // cppcheck-suppress incorrectLogicOperator assert(fd == NULL || fd != NULL); /* Hack: fd == NULL for OPTIONS */ -HOOKDEBUG(-1, (stderr, "<-- %s(%p,%p,%p) sess %p fd %p %s\n", __FUNCTION__, req, userdata, status, sess, fd, ne_get_error(sess))); +HOOKDEBUG(-1, "<-- %s(%p,%p,%p) sess %p fd %p %s\n", __FUNCTION__, req, userdata, status, sess, fd, ne_get_error(sess)); } static int davPostSend(ne_request * req, void * userdata, const ne_status * status) @@ -534,10 +534,10 @@ u->location = xstrdup(value); } rc = NE_REDIRECT; -DAVDEBUG(-1, (stderr, "\t%d Location: %s\n", status->code, value)); +DAVDEBUG(-1, "\t%d Location: %s\n", status->code, value); } -HOOKDEBUG(-1, (stderr, "<-- %s(%p,%p,%p) rc %d sess %p u %p fd %p %s\n", __FUNCTION__, req, userdata, status, rc, sess, u, fd, ne_get_error(sess))); +HOOKDEBUG(-1, "<-- %s(%p,%p,%p) rc %d sess %p u %p fd %p %s\n", __FUNCTION__, req, userdata, status, rc, sess, u, fd, ne_get_error(sess)); return rc; } @@ -551,21 +551,21 @@ /* HACK: davConnect() -> ne_options2() needs fd->req unregistered. */ -HOOKDEBUG(-1, (stderr, "<-- %s(%p,%p) sess %p fd %p\n", __FUNCTION__, req, userdata, sess, fd)); +HOOKDEBUG(-1, "<-- %s(%p,%p) sess %p fd %p\n", __FUNCTION__, req, userdata, sess, fd); } static void davCloseConn(void * userdata) { ne_session * sess = req2sess(NULL, userdata, __FUNCTION__); -HOOKDEBUG(-1, (stderr, "<-- %s(%p) sess %p\n", __FUNCTION__, userdata, sess)); +HOOKDEBUG(-1, "<-- %s(%p) sess %p\n", __FUNCTION__, userdata, sess); } static void davDestroySession(void * userdata) { ne_session * sess = req2sess(NULL, userdata, __FUNCTION__); -HOOKDEBUG(-1, (stderr, "<-- %s(%p) sess %p\n", __FUNCTION__, userdata, sess)); +HOOKDEBUG(-1, "<-- %s(%p) sess %p\n", __FUNCTION__, userdata, sess); } int davFree(urlinfo u) @@ -602,7 +602,7 @@ break; } } -DAVDEBUG(-1, (stderr, "<-- %s(%p) url %s\n", __FUNCTION__, u, url)); +DAVDEBUG(-1, "<-- %s(%p) url %s\n", __FUNCTION__, u, url); url = _free(url); return 0; } @@ -654,7 +654,7 @@ const char *hostname = (const char *) userdata; int rc = 0; /* HACK: trust all server certificates. */ -DAVDEBUG(-1, (stderr, "<-- %s(%p,%d,%p) rc %d %s\n", __FUNCTION__, userdata, failures, cert, rc, hostname)); +DAVDEBUG(-1, "<-- %s(%p,%d,%p) rc %d %s\n", __FUNCTION__, userdata, failures, cert, rc, hostname); return rc; /* HACK: trust all server certificates. */ } @@ -667,7 +667,7 @@ int ut = urlPath(u->url, &path); int rc = NE_CONNECT; /* assume failure */ -DAVDEBUG(-1, (stderr, "--> %s(%p) url %s\n", __FUNCTION__, u, u->url)); +DAVDEBUG(-1, "--> %s(%p) url %s\n", __FUNCTION__, u, u->url); /* HACK: hkp:// has no steenkin' options */ switch (ut) { @@ -769,7 +769,7 @@ case NE_RETRY: default: bottom: -DAVDEBUG(-1, (stderr, "*** Connect to %s:%d failed(%d):\n\t%s\n", u->host, u->port, rc, ne_get_error((ne_session *)u->sess))); +DAVDEBUG(-1, "*** Connect to %s:%d failed(%d):\n\t%s\n", u->host, u->port, rc, ne_get_error((ne_session *)u->sess)); break; } @@ -779,7 +779,7 @@ /* HACK: find the REDIRECTed url: davInit recursion fubarage */ -DAVDEBUG(-1, (stderr, "<-- %s(%p) rc %d\n", __FUNCTION__, u, rc)); +DAVDEBUG(-1, "<-- %s(%p) rc %d\n", __FUNCTION__, u, rc); return rc; } @@ -794,7 +794,7 @@ if (urlSplit(url, &u)) return -1; /* XXX error returns needed. */ if (u->location) { -DAVDEBUG(-1,(stderr, "\tREDIRECT %s -> %s\n", url, u->location)); +DAVDEBUG(-1, "\tREDIRECT %s -> %s\n", url, u->location); url = u->location; continue; } @@ -900,7 +900,7 @@ } exit: -DAVDEBUG(-1, (stderr, "<-- %s(%s) rc %d u->url %s\n", __FUNCTION__, url, rc, u->url)); +DAVDEBUG(-1, "<-- %s(%s) rc %d u->url %s\n", __FUNCTION__, url, rc, u->url); if (uret != NULL) *uret = urlLink(u, "davInit"); u = urlFree(u, "urlSplit (davInit)"); @@ -1041,11 +1041,11 @@ newres = (struct fetch_resource_s *) ne_propset_private(set); -DAVDEBUG(-1, (stderr, "==> %s in uri %s\n", path, avx->uri)); +DAVDEBUG(-1, "==> %s in uri %s\n", path, avx->uri); if (ne_path_compare(avx->uri, path) == 0) { /* This is the target URI */ -DAVDEBUG(-1, (stderr, "==> %s skipping target resource.\n", path)); +DAVDEBUG(-1, "==> %s skipping target resource.\n", path); /* Free the private structure. */ free(newres); return; @@ -1243,7 +1243,7 @@ FD_t ctrl = NULL; int xx; -DAVDEBUG(-1, (stderr, "--> %s(%p,%p) url %s\n", __FUNCTION__, u, st, url)); +DAVDEBUG(-1, "--> %s(%p,%p) url %s\n", __FUNCTION__, u, st, url); /* ======================= */ /* HACK: find the REDIRECTed url: davInit recursion fubarage */ @@ -1252,7 +1252,7 @@ if (urlSplit(url, &v)) return -1; /* XXX error returns needed. */ if (v->location) { -DAVDEBUG(-1, (stderr, "\tREDIRECT %s -> %s\n", url, v->location)); +DAVDEBUG(-1, "\tREDIRECT %s -> %s\n", url, v->location); url = v->location; continue; } @@ -1318,7 +1318,7 @@ fprintf(stderr, "HTTP request sent, awaiting response... %d %s\n", status->code, status->reason_phrase); #else /* RPM_VENDOR_PLD */ /* XXX somewhere else instead? */ -DAVDEBUG(1, (stderr, "HTTP request sent, awaiting response... %d %s\n", status->code, status->reason_phrase)); +DAVDEBUG(1, "HTTP request sent, awaiting response... %d %s\n", status->code, status->reason_phrase); switch (rc) { case NE_OK: @@ -1454,7 +1454,7 @@ xx = ufdClose(v->ctrl); v->ctrl = NULL; -DAVDEBUG(-1, (stderr, "<-- %s(%p,%p) rc %d\n", __FUNCTION__, u, st, rc)); +DAVDEBUG(-1, "<-- %s(%p,%p) rc %d\n", __FUNCTION__, u, st, rc); return rc; } @@ -1558,7 +1558,7 @@ b += html->nb; nb -= html->nb; } -DAVDEBUG(-1, (stderr, "--> %s(%p) %p[%u]\n", __FUNCTION__, html, b, (unsigned)nb)); +DAVDEBUG(-1, "--> %s(%p) %p[%u]\n", __FUNCTION__, html, b, (unsigned)nb); /* XXX FIXME: "server awol" segfaults here. gud enuf atm ... */ rc = ne_read_response_block(html->req, b, nb); @@ -1569,7 +1569,7 @@ } html->b = html->buf; -DAVDEBUG(-1, (stderr, "<-- %s(%p) %p[%u] rc %d\n", __FUNCTION__, html, b, (unsigned)nb, (int)rc)); +DAVDEBUG(-1, "<-- %s(%p) %p[%u] rc %d\n", __FUNCTION__, html, b, (unsigned)nb, (int)rc); return rc; } @@ -1603,7 +1603,7 @@ int rc = 0; int xx; -DAVDEBUG(-1, (stderr, "--> %s(%p) %p[%u]\n", __FUNCTION__, html, html->buf, (unsigned)html->nbuf)); +DAVDEBUG(-1, "--> %s(%p) %p[%u]\n", __FUNCTION__, html, html->buf, (unsigned)html->nbuf); if (st) { st->st_mode |= 0755; /* htmlParse() is always a directory. */ @@ -1774,7 +1774,7 @@ html->mires = (miRE) mireFreeAll(html->mires, html->nmires); html->nmires = 0; -DAVDEBUG(-1, (stderr, "<-- %s(%p) rc %d\n", __FUNCTION__, html, rc)); +DAVDEBUG(-1, "<-- %s(%p) rc %d\n", __FUNCTION__, html, rc); return rc; } @@ -1899,8 +1899,8 @@ case NE_RETRY: case NE_REDIRECT: default: -DAVDEBUG(1, (stderr, "*** Fetch from %s:%d failed rc(%d):\n\t%s\n", - u->host, u->port, rc, ne_get_error((ne_session *)u->sess))); +DAVDEBUG(1, "*** Fetch from %s:%d failed rc(%d):\n\t%s\n", + u->host, u->port, rc, ne_get_error((ne_session *)u->sess)); break; } @@ -1920,7 +1920,7 @@ { int rc = 0; -DAVDEBUG(-1, (stderr, "--> %s(%p,%p,%p) sess %p req %p\n", __FUNCTION__, u, ctrl, str, u->sess, ctrl->req)); +DAVDEBUG(-1, "--> %s(%p,%p,%p) sess %p req %p\n", __FUNCTION__, u, ctrl, str, u->sess, ctrl->req); /* HACK: ne_request_dispatch ALTERNATIVE to ne_{begin,end}_request */ rc = davCheck(ctrl->req, "ne_begin_request", @@ -1930,7 +1930,7 @@ if (rc) fdSetSyserrno(ctrl, errno, ftpStrerror(-rc)); -DAVDEBUG(-1, (stderr, "<-- %s(%p,%p,%p) sess %p req %p rc %d\n", __FUNCTION__, u, ctrl, str, u->sess, ctrl->req, rc)); +DAVDEBUG(-1, "<-- %s(%p,%p,%p) sess %p req %p rc %d\n", __FUNCTION__, u, ctrl, str, u->sess, ctrl->req, rc); return rc; } @@ -1945,10 +1945,10 @@ (void)ut; -DAVDEBUG(-1, (stderr, "--> %s(%p,%s,\"%s\") entry sess %p req %p\n", __FUNCTION__, ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req)); +DAVDEBUG(-1, "--> %s(%p,%s,\"%s\") entry sess %p req %p\n", __FUNCTION__, ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req); if (strncmp(httpArg, path, npath)) { -DAVDEBUG(-1, (stderr, "\tREDIRECT %s -> %s\n", httpArg, path)); +DAVDEBUG(-1, "\tREDIRECT %s -> %s\n", httpArg, path); httpArg = path; } @@ -2033,7 +2033,7 @@ if (rc) goto errxit; -DAVDEBUG(-1, (stderr, "<-- %s(%p,%s,\"%s\") exit sess %p req %p rc %d\n", __FUNCTION__, ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req, rc)); +DAVDEBUG(-1, "<-- %s(%p,%s,\"%s\") exit sess %p req %p rc %d\n", __FUNCTION__, ctrl, httpCmd, (httpArg ? httpArg : ""), u->sess, ctrl->req, rc); #if defined(HAVE_NEON_NE_GET_RESPONSE_HEADER) @@ -2087,7 +2087,7 @@ assert(!(flags & O_RDWR)); #endif -DAVDEBUG(-1, (stderr, "--> %s(%s,0x%x,0%o,%p)\n", __FUNCTION__, url, flags, (unsigned)mode, uret)); +DAVDEBUG(-1, "--> %s(%s,0x%x,0%o,%p)\n", __FUNCTION__, url, flags, (unsigned)mode, uret); rc = davInit(url, &u); if (rc || u == NULL || u->sess == NULL) goto exit; @@ -2152,7 +2152,7 @@ u = urlFree(u, "url (davRead)"); } -DAVDEBUG(-1, (stderr, "<-- %s(%p,%p,0x%x) rc 0x%x\n", __FUNCTION__, cookie, buf, (unsigned)count, (unsigned)rc)); +DAVDEBUG(-1, "<-- %s(%p,%p,0x%x) rc 0x%x\n", __FUNCTION__, cookie, buf, (unsigned)count, (unsigned)rc); return rc; } @@ -2187,7 +2187,7 @@ /* HACK: stupid error impedance matching. */ rc = (xx == 0 ? (ssize_t)count : -1); -DAVDEBUG(-1, (stderr, "<-- %s(%p,%p,0x%x) rc 0x%x\n", __FUNCTION__, cookie, buf, (unsigned)count, (unsigned)rc)); +DAVDEBUG(-1, "<-- %s(%p,%p,0x%x) rc 0x%x\n", __FUNCTION__, cookie, buf, (unsigned)count, (unsigned)rc); return rc; } @@ -2195,7 +2195,7 @@ int davSeek(void * cookie, _libio_pos_t pos, int whence) { int rc = -1; -DAVDEBUG(-1, (stderr, "<-- %s(%p,pos,%d) rc %d\n", __FUNCTION__, cookie, whence, rc)); +DAVDEBUG(-1, "<-- %s(%p,pos,%d) rc %d\n", __FUNCTION__, cookie, whence, rc); return rc; } @@ -2204,7 +2204,7 @@ FD_t fd = (FD_t) cookie; int rc = 0; -DAVDEBUG(-1, (stderr, "--> %s(%p) rc %d clen %d req %p u %p\n", __FUNCTION__, fd, rc, (int)fd->bytesRemain, fd->req, fd->u)); +DAVDEBUG(-1, "--> %s(%p) rc %d clen %d req %p u %p\n", __FUNCTION__, fd, rc, (int)fd->bytesRemain, fd->req, fd->u); assert(fd->req != NULL); if (fd->req != (void *)-1) { @@ -2215,7 +2215,7 @@ } fd->req = (void *)NULL; -DAVDEBUG(-1, (stderr, "<-- %s(%p) rc %d\n", __FUNCTION__, fd, rc)); +DAVDEBUG(-1, "<-- %s(%p) rc %d\n", __FUNCTION__, fd, rc); return rc; } @@ -2241,7 +2241,7 @@ /* XXX HACK: verify getrestype(remote) == resr_collection */ exit: -DAVDEBUG(1, (stderr, "<-- %s(%s,0%o) rc %d\n", __FUNCTION__, path, (unsigned)mode, rc)); +DAVDEBUG(1, "<-- %s(%s,0%o) rc %d\n", __FUNCTION__, path, (unsigned)mode, rc); return rc; } @@ -2266,7 +2266,7 @@ if (rc) rc = -1; /* XXX HACK: errno impedance match */ exit: -DAVDEBUG(1, (stderr, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc)); +DAVDEBUG(1, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); return rc; } @@ -2294,7 +2294,7 @@ if (rc) rc = -1; /* XXX HACK: errno impedance match */ exit: -DAVDEBUG(1, (stderr, "<-- %s(%s,%s) rc %d\n", __FUNCTION__, oldpath, newpath, rc)); +DAVDEBUG(1, "<-- %s(%s,%s) rc %d\n", __FUNCTION__, oldpath, newpath, rc); return rc; } @@ -2319,7 +2319,7 @@ exit: if (rc) rc = -1; /* XXX HACK: errno impedance match */ -DAVDEBUG(1, (stderr, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc)); +DAVDEBUG(1, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); return rc; } @@ -2353,7 +2353,7 @@ char buf[1024]; int rc = -1; -DAVDEBUG(-1, (stderr, "--> %s(%s)\n", __FUNCTION__, path)); +DAVDEBUG(-1, "--> %s(%s)\n", __FUNCTION__, path); if (path == NULL || *path == '\0') { errno = ENOENT; goto exit; @@ -2377,14 +2377,14 @@ /* XXX rpmct.c does Lstat() -> Fchmod() on target fd. */ /* XXX HACK: ensure st->st_mode is sane, not 0000 */ if ((st->st_mode & 07777) == 00000) - switch(st->st_mode) { + switch (st->st_mode) { case S_IFDIR: st->st_mode |= 0755; break; default: case S_IFREG: st->st_mode |= 0644; break; } exit: -DAVDEBUG(-1, (stderr, "<-- %s(%s) rc %d\n\t%s\n", __FUNCTION__, path, rc, statstr(st, buf))); +DAVDEBUG(-1, "<-- %s(%s) rc %d\n\t%s\n", __FUNCTION__, path, rc, statstr(st, buf)); avx = rpmavxFree(avx); return rc; } @@ -2425,7 +2425,7 @@ } -DAVDEBUG(-1, (stderr, "<-- %s(%s) rc %d\n\t%s\n", __FUNCTION__, path, rc, statstr(st, buf))); +DAVDEBUG(-1, "<-- %s(%s) rc %d\n\t%s\n", __FUNCTION__, path, rc, statstr(st, buf)); exit: avx = rpmavxFree(avx); return rc; @@ -2436,7 +2436,7 @@ { int rc; rc = davNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz); -DAVDEBUG(-1, (stderr, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc)); +DAVDEBUG(-1, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); return rc; } #endif /* NOTYET */ @@ -2512,7 +2512,7 @@ const char * uri = NULL; int rc; -DAVDEBUG(-1, (stderr, "--> %s(%s)\n", __FUNCTION__, path)); +DAVDEBUG(-1, "--> %s(%s)\n", __FUNCTION__, path); if (path == NULL || *path == '\0') { errno = ENOENT; @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmdir.c ============================================================================ $ cvs diff -u -r2.12.2.14 -r2.12.2.15 rpmdir.c --- rpm/rpmio/rpmdir.c 26 May 2017 20:49:23 -0000 2.12.2.14 +++ rpm/rpmio/rpmdir.c 14 Jul 2017 11:23:13 -0000 2.12.2.15 @@ -16,6 +16,9 @@ #include "debug.h" int _rpmdir_debug; +#define SPEW(_fmt, ...) \ + if (_rpmdir_debug || _rpmio_debug) \ + fprintf(stderr, _fmt, __VA_ARGS__) #ifdef __cplusplus GENfree(time_t *) @@ -362,8 +365,7 @@ /* =============================================================== */ int Closedir(DIR * dir) { -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Closedir(%p)\n", (void *)dir); +SPEW("*** Closedir(%p)\n", (void *)dir); if (dir == NULL) return 0; if (ISAVMAGIC(dir)) @@ -376,8 +378,7 @@ const char * lpath; int ut = urlPath(path, &lpath); -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Opendir(%s)\n", path); +SPEW("*** Opendir(%s)\n", path); switch (ut) { case URL_IS_FTP: return ftpOpendir(path); @@ -405,8 +406,7 @@ struct dirent * Readdir(DIR * dir) { -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Readdir(%p)\n", (void *)dir); +SPEW("*** Readdir(%p)\n", (void *)dir); if (dir == NULL) return NULL; if (ISAVMAGIC(dir)) @@ -416,8 +416,7 @@ void Rewinddir(DIR * dir) { -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Rewinddir(%p)\n", (void *)dir); +SPEW("*** Rewinddir(%p)\n", (void *)dir); if (ISAVMAGIC(dir)) avRewinddir(dir); else @@ -454,8 +453,7 @@ rc = scandir(lpath, nl, filter, (int (*)(const struct dirent **, const struct dirent **))compar); -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Scandir(\"%s\", %p, %p, %p) rc %d\n", path, nl, filter, compar, rc); +SPEW("*** Scandir(\"%s\", %p, %p, %p) rc %d\n", path, nl, filter, compar, rc); return rc; } @@ -483,8 +481,7 @@ void Seekdir(DIR * dir, off_t offset) { -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Seekdir(%p,%ld)\n", (void *)dir, (long)offset); +SPEW("*** Seekdir(%p,%ld)\n", (void *)dir, (long)offset); if (ISAVMAGIC(dir)) avSeekdir(dir, offset); else @@ -497,7 +494,6 @@ off_t offset = 0; offset = (ISAVMAGIC(dir) ? avTelldir(dir) : telldir(dir)); -if (_rpmio_debug || _rpmdir_debug) -fprintf(stderr, "*** Telldir(%p) off %ld\n", (void *)dir, (long)offset); +SPEW("*** Telldir(%p) off %ld\n", (void *)dir, (long)offset); return offset; } @@ . patch -p0 <<'@@ .' Index: rpm/rpmio/rpmrpc.c ============================================================================ $ cvs diff -u -r2.99.2.14 -r2.99.2.15 rpmrpc.c --- rpm/rpmio/rpmrpc.c 20 May 2017 13:42:14 -0000 2.99.2.14 +++ rpm/rpmio/rpmrpc.c 14 Jul 2017 11:23:13 -0000 2.99.2.15 @@ -10,6 +10,7 @@ #include <rpmio_internal.h> #include <rpmmacro.h> +#include <rpmurl.h> #define _RPMDIR_INTERNAL #include <rpmdir.h> @@ -21,6 +22,16 @@ #include "debug.h" +extern int _rpmio_debug; +#define SPEW(_fmt, ...) \ + if (_rpmio_debug) \ + fprintf(stderr, _fmt, __VA_ARGS__) + +extern int _ftp_debug; +#define FTPSPEW(_fmt, ...) \ + if (_ftp_debug) \ + fprintf(stderr, _fmt, __VA_ARGS__) + /* =============================================================== */ static int ftpMkdir(const char * path, mode_t mode) { @@ -66,8 +77,7 @@ const char * lpath; int ut = urlPath(path, &lpath); -if (_rpmio_debug) -fprintf(stderr, "*** Mkdir(%s, 0%o)\n", path, (unsigned)mode); +SPEW("*** Mkdir(%s, 0%o)\n", path, (unsigned)mode); switch (ut) { case URL_IS_FTP: return ftpMkdir(path, mode); @@ -99,8 +109,7 @@ const char * lpath; int ut = urlPath(path, &lpath); -if (_rpmio_debug) -fprintf(stderr, "*** Chdir(%s)\n", path); +SPEW("*** Chdir(%s)\n", path); switch (ut) { case URL_IS_FTP: return ftpChdir(path); @@ -136,8 +145,7 @@ const char * lpath; int ut = urlPath(path, &lpath); -if (_rpmio_debug) -fprintf(stderr, "*** Rmdir(%s)\n", path); +SPEW("*** Rmdir(%s)\n", path); switch (ut) { case URL_IS_FTP: return ftpRmdir(path); @@ -195,8 +203,7 @@ rc = chroot(path); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s) prefix %s rc %d\n", __FUNCTION__, path, _chroot_prefix, rc); +SPEW("<-- %s(%s) prefix %s rc %d\n", __FUNCTION__, path, _chroot_prefix, rc); return rc; } @@ -264,8 +271,7 @@ #endif #endif -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s, 0x%x, 0%o) prefix %s fdno %d\n", __FUNCTION__, path, flags, (unsigned)mode, _chroot_prefix, fdno); +SPEW("<-- %s(%s, 0x%x, 0%o) prefix %s fdno %d\n", __FUNCTION__, path, flags, (unsigned)mode, _chroot_prefix, fdno); return fdno; } @@ -279,8 +285,7 @@ const char *ne = NULL; int oldut, newut; -if (_rpmio_debug) -fprintf(stderr, "*** Rename(%s, %s)\n", oldpath, newpath); +SPEW("*** Rename(%s, %s)\n", oldpath, newpath); /* XXX lib/install.c used to rely on this behavior. */ if (!strcmp(oldpath, newpath)) return 0; @@ -307,8 +312,7 @@ newut = urlPath(newpath, &ne); switch (newut) { case URL_IS_FTP: -if (_rpmio_debug) -fprintf(stderr, "*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath); +SPEW("*** rename old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath); if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) && !xstrncasecmp(oldpath, newpath, (oe - oldpath)))) return rc; @@ -339,8 +343,7 @@ const char *ne = NULL; int oldut, newut; -if (_rpmio_debug) -fprintf(stderr, "*** Link(%s, %s)\n", oldpath, newpath); +SPEW("*** Link(%s, %s)\n", oldpath, newpath); oldut = urlPath(oldpath, &oe); switch (oldut) { case URL_IS_HTTPS: /* XXX WRONG WRONG WRONG */ @@ -363,8 +366,7 @@ case URL_IS_HTTP: /* XXX WRONG WRONG WRONG */ case URL_IS_FTP: /* XXX WRONG WRONG WRONG */ case URL_IS_PATH: -if (_rpmio_debug) -fprintf(stderr, "*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath); +SPEW("*** link old %*s new %*s\n", (int)(oe - oldpath), oldpath, (int)(ne - newpath), newpath); if (!(oldut == newut && oe && ne && (oe - oldpath) == (ne - newpath) && !xstrncasecmp(oldpath, newpath, (oe - oldpath)))) return rc; @@ -413,8 +415,7 @@ } rc = unlink(path); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); +SPEW("<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); return rc; } @@ -1167,8 +1168,7 @@ if (st->st_ino == 0) st->st_ino = hashFunctionString(0, path, 0); -if (_ftp_debug) -fprintf(stderr, "<-- %s(%s) rc %d\n%s", __FUNCTION__, path, rc, statstr(st, buf)); +FTPSPEW("<-- %s(%s) rc %d\n%s", __FUNCTION__, path, rc, statstr(st, buf)); return rc; } @@ -1184,8 +1184,7 @@ if (st->st_ino == 0) st->st_ino = hashFunctionString(0, path, 0); -if (_ftp_debug) -fprintf(stderr, "<-- %s(%s) rc %d\n%s\n", __FUNCTION__, path, rc, statstr(st, buf)); +FTPSPEW("<-- %s(%s) rc %d\n%s\n", __FUNCTION__, path, rc, statstr(st, buf)); return rc; } @@ -1193,8 +1192,7 @@ { int rc; rc = ftpNLST(path, DO_FTP_READLINK, NULL, buf, bufsiz); -if (_ftp_debug) -fprintf(stderr, "<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); +FTPSPEW("<-- %s(%s) rc %d\n", __FUNCTION__, path, rc); return rc; } @@ -1208,8 +1206,7 @@ int c; int rc; -if (_ftp_debug) -fprintf(stderr, "*** ftpOpendir(%s)\n", path); +FTPSPEW("*** %s(%s)\n", __FUNCTION__, path); /* Load FTP collection into argv. */ avx = (rpmavx) rpmavxNew(path, st); @@ -1331,8 +1328,7 @@ } rc = stat(path, st); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s,%p) rc %d\n", __FUNCTION__, path, st, rc); +SPEW("<-- %s(%s,%p) rc %d\n", __FUNCTION__, path, st, rc); return rc; } @@ -1369,8 +1365,7 @@ } rc = lstat(path, st); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s,%p) rc %d\n", __FUNCTION__, path, st, rc); +SPEW("<-- %s(%s,%p) rc %d\n", __FUNCTION__, path, st, rc); return rc; } @@ -1426,8 +1421,7 @@ } rc = fstat(Fileno(fd), st); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p,%p) path %s rc %d\n", __FUNCTION__, fd, st, path, rc); +SPEW("<-- %s(%p,%p) path %s rc %d\n", __FUNCTION__, fd, st, path, rc); return rc; } @@ -1440,8 +1434,7 @@ rpmlog(RPMLOG_ERR, _("%s(%p[%u],0x%x,0x%x,%p,0x%x) failed: %m\n"), __FUNCTION__, addr, (unsigned)len, prot, flags, fd, (unsigned)offset); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u],0x%x,0x%x,%p,0x%x) ret %p\n", __FUNCTION__, addr, (unsigned)len, prot, flags, fd, (unsigned)offset, ret); +SPEW("<-- %s(%p[%u],0x%x,0x%x,%p,0x%x) ret %p\n", __FUNCTION__, addr, (unsigned)len, prot, flags, fd, (unsigned)offset, ret); return ret; } @@ -1451,8 +1444,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u]) failed: %m\n"), __FUNCTION__, addr, (unsigned)len); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u]) rc %d\n", __FUNCTION__, addr, (unsigned)len, rc); +SPEW("<-- %s(%p[%u]) rc %d\n", __FUNCTION__, addr, (unsigned)len, rc); return rc; } @@ -1462,8 +1454,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u],%d) failed: %m\n"), __FUNCTION__, addr, (unsigned)len, flags); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, flags, rc); +SPEW("<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, flags, rc); return rc; } @@ -1477,8 +1468,7 @@ if (ret == NULL || ret == MAP_FAILED) rpmlog(RPMLOG_ERR, _("%s(%p[%u => %u],%d,%p) failed: %m\n"), __FUNCTION__, oaddr, (unsigned)olen, (unsigned)nlen, flags, naddr); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u => %u],%d,%p) ret %p\n", __FUNCTION__, oaddr, (unsigned)olen, (unsigned)nlen, flags, naddr, ret); +SPEW("<-- %s(%p[%u => %u],%d,%p) ret %p\n", __FUNCTION__, oaddr, (unsigned)olen, (unsigned)nlen, flags, naddr, ret); return ret; } @@ -1488,8 +1478,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u],%d) failed: %m\n"), __FUNCTION__, addr, (unsigned)len, prot); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, prot, rc); +SPEW("<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, prot, rc); return rc; } @@ -1499,8 +1488,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u],%d) failed: %m\n"), __FUNCTION__, addr, (unsigned)len, advice); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, advice, rc); +SPEW("<-- %s(%p[%u],%d) rc %d\n", __FUNCTION__, addr, (unsigned)len, advice, rc); return rc; } @@ -1510,8 +1498,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u],%p) failed: %m\n"), __FUNCTION__, addr, (unsigned)len, vec); -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%p[%u],%p) rc %d\n", __FUNCTION__, addr, (unsigned)len, vec, rc); +SPEW("<-- %s(%p[%u],%p) rc %d\n", __FUNCTION__, addr, (unsigned)len, vec, rc); return rc; } @@ -1534,8 +1521,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%p[%u],0x%x) failed: %m\n"), __FUNCTION__, buf, (unsigned)buflen, flags); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%p[%u],0x%x) rc %d\n"), __FUNCTION__, buf, (unsigned)buflen, flags, rc); +SPEW("<-- %s(%p[%u],0x%x) rc %d\n", __FUNCTION__, buf, (unsigned)buflen, flags, rc); return rc; } @@ -1558,8 +1544,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%d, %d, %p, %u) failed: %m\n"), __FUNCTION__, out_fd, in_fd, offset, (unsigned)count); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%d, %d, %p, %u) rc %d\n"), __FUNCTION__, out_fd, in_fd, offset, (unsigned)count, rc); +SPEW("<-- %s(%d, %d, %p, %u) rc %d\n", __FUNCTION__, out_fd, in_fd, offset, (unsigned)count, rc); return rc; } @@ -1581,8 +1566,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%d,%p, %d,%p, %u, %u) failed: %m\n"), __FUNCTION__, fd_in, off_in, fd_out, off_out, (unsigned)len, flags); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%d,%p, %d,%p, %u, %u) rc %ld\n"), +SPEW("<-- %s(%d,%p, %d,%p, %u, %u) rc %ld\n", __FUNCTION__, fd_in, off_in, fd_out, off_out, (unsigned)len, flags, rc); return rc; } @@ -1605,8 +1589,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%d,%p, %d,%p, %u, %u) failed: %m\n"), __FUNCTION__, fd_in, off_in, fd_out, off_out, (unsigned)len, flags); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%d,%p, %d,%p, %u, %u) rc %d\n"), __FUNCTION__, fd_in, off_in, fd_out, off_out, (unsigned)len, flags, rc); +SPEW("<-- %s(%d,%p, %d,%p, %u, %u) rc %d\n", __FUNCTION__, fd_in, off_in, fd_out, off_out, (unsigned)len, flags, rc); return rc; } @@ -1625,8 +1608,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%d, %d, %u, %u) failed: %m\n"), __FUNCTION__, fd_in, fd_out, (unsigned)len, flags); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%d, %d, %u, %u) rc %d\n"), __FUNCTION__, fd_in, fd_out, (unsigned)len, flags, rc); +SPEW("<-- %s(%d, %d, %u, %u) rc %d\n", __FUNCTION__, fd_in, fd_out, (unsigned)len, flags, rc); return rc; } @@ -1647,8 +1629,7 @@ if (rc < 0) rpmlog(RPMLOG_ERR, _("%s(%d, %p, %u, %u) failed: %m\n"), __FUNCTION__, fd, iov, (unsigned)nr_segs, flags); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(%d, %p, %u, %u) rc %d\n"), __FUNCTION__, fd, iov, (unsigned)nr_segs, flags, rc); +SPEW("<-- %s(%d, %p, %u, %u) rc %d\n", __FUNCTION__, fd, iov, (unsigned)nr_segs, flags, rc); return rc; } @@ -1750,8 +1731,7 @@ if (rc == 0) rpmlog(RPMLOG_ERR, _("%s(AT_%s) failed: rc 0x%lx %m\n"), __FUNCTION__, fmtATtype(type), rc); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(AT_%s) rc 0x%lx\n"), __FUNCTION__, fmtATtype(type), rc); +SPEW("<-- %s(AT_%s) rc 0x%lx\n", __FUNCTION__, fmtATtype(type), rc); return rc; } @@ -1762,7 +1742,9 @@ static KEY PERsona[] = { _ENTRY(LINUX), _ENTRY(LINUX_32BIT), +#if defined(PER_LINUX_FDPIC) _ENTRY(LINUX_FDPIC), +#endif _ENTRY(SVR4), _ENTRY(SVR3), _ENTRY(SCOSVR3), @@ -1802,8 +1784,7 @@ if (rc == -1) rpmlog(RPMLOG_ERR, _("%s(PER_%s) failed: %m\n"), __FUNCTION__, fmtPERsona(persona)); -if (_rpmio_debug) -fprintf(stderr, _("<-- %s(PER_%s) was PER_%s\n"), __FUNCTION__, fmtPERsona(persona), (rc != -1 ? fmtPERsona(rc) : "ERROR")); +SPEW("<-- %s(PER_%s) was PER_%s\n", __FUNCTION__, fmtPERsona(persona), (rc != -1 ? fmtPERsona(rc) : "ERROR")); return rc; } @@ -1956,8 +1937,7 @@ } rc = symlink(oldpath, newpath); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s,%s) rc %d\n", __FUNCTION__, oldpath, newpath, rc); +SPEW("<-- %s(%s,%s) rc %d\n", __FUNCTION__, oldpath, newpath, rc); return rc; } @@ -1994,8 +1974,7 @@ } rc = readlink(path, buf, bufsiz); exit: -if (_rpmio_debug) -fprintf(stderr, "<-- %s(%s,%p[%u]) rc %d\n", __FUNCTION__, path, buf, (unsigned)bufsiz, rc); +SPEW("<-- %s(%s,%p[%u]) rc %d\n", __FUNCTION__, path, buf, (unsigned)bufsiz, rc); return rc; } @@ -2068,8 +2047,7 @@ int ut = urlPath(pattern, &lpath); const char *home = getenv("HOME"); -if (_rpmio_debug) -fprintf(stderr, "*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob); +SPEW("*** Glob(%s,0x%x,%p,%p)\n", pattern, (unsigned)flags, (void *)errfunc, pglob); switch (ut) { case URL_IS_HTTPS: case URL_IS_HTTP: @@ -2104,8 +2082,7 @@ void Globfree(void *_pglob) { glob_t *pglob = (glob_t *) _pglob; -if (_rpmio_debug) -fprintf(stderr, "*** Globfree(%p)\n", pglob); +SPEW("*** Globfree(%p)\n", pglob); globfree(pglob); } @@ -2115,8 +2092,7 @@ int ut = urlPath(path, &lpath); char * rpath = NULL; -if (_rpmio_debug) -fprintf(stderr, "*** Realpath(%s, %s)\n", path, (resolved_path ? resolved_path : "NULL")); +SPEW("*** Realpath(%s, %s)\n", path, (resolved_path ? resolved_path : "NULL")); /* XXX if POSIXly broken realpath(3) is desired, do that. */ /* XXX note: preserves current rpmlib realpath(3) usage cases. */ if (path == NULL || resolved_path != NULL) @@ -2188,7 +2164,6 @@ off_t Lseek(int fdno, off_t offset, int whence) { -if (_rpmio_debug) -fprintf(stderr, "*** Lseek(%d,0x%lx,%d)\n", fdno, (long)offset, whence); +SPEW("*** Lseek(%d,0x%lx,%d)\n", fdno, (long)offset, whence); return lseek(fdno, offset, whence); } @@ . ______________________________________________________________________ RPM Package Manager http://rpm5.org CVS Sources Repository [email protected]
