[dpkg] 89/187: Cast off_t variables to intmax_t when printing them with %jd

Reiner Herrmann reiner at reiner-h.de
Sun Nov 6 12:46:28 UTC 2016


This is an automated email from the git hooks/post-receive script.

deki-guest pushed a commit to branch master
in repository dpkg.

commit f10a135c0e22cac01a68c08a3aea2303eb7d4f37
Author: Guillem Jover <guillem at debian.org>
Date:   Tue Aug 23 21:33:48 2016 +0200

    Cast off_t variables to intmax_t when printing them with %jd
    
    Warned-by: clang
---
 debian/changelog          | 2 ++
 dpkg-deb/extract.c        | 2 +-
 lib/dpkg/ar.c             | 2 +-
 lib/dpkg/t/c-tarextract.c | 7 ++++---
 src/archives.c            | 4 ++--
 src/configure.c           | 3 ++-
 6 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 559e808..da3c818 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -30,6 +30,8 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
     output substvar prefixed with “S:”.
   * Make dpkg-source generate reproducible source packages when run
     standalone, by honoring SOURCE_DATE_EPOCH.
+  * Portability:
+    - Cast off_t variables to intmax_t when printing them with "%jd".
   * Perl modules:
     - Obsolete Source-Version substvar in Dpkg::Substvars by emitting errors.
     - Rework keyring hooks in Dpkg::Vendor. Deprecate the keyrings hook, and
diff --git a/dpkg-deb/extract.c b/dpkg-deb/extract.c
index b46851c..d486c6d 100644
--- a/dpkg-deb/extract.c
+++ b/dpkg-deb/extract.c
@@ -242,7 +242,7 @@ extracthalf(const char *debar, const char *dir,
     r = read_line(ar->fd, ctrllenbuf, 1, sizeof(ctrllenbuf) - 1);
     if (r < 0)
       read_fail(r, debar, _("archive control member size"));
-    if (sscanf(ctrllenbuf, "%jd%c%d", &ctrllennum, &nlc, &dummy) != 2 ||
+    if (sscanf(ctrllenbuf, "%jd%c%d", (intmax_t *)&ctrllennum, &nlc, &dummy) != 2 ||
         nlc != '\n')
       ohshit(_("archive has malformatted control member size '%s'"), ctrllenbuf);
 
diff --git a/lib/dpkg/ar.c b/lib/dpkg/ar.c
index 0aec95d..8a84c67 100644
--- a/lib/dpkg/ar.c
+++ b/lib/dpkg/ar.c
@@ -171,7 +171,7 @@ dpkg_ar_member_put_header(struct dpkg_ar *ar, struct dpkg_ar_member *member)
 	if (strlen(member->name) > 15)
 		ohshit(_("ar member name '%s' length too long"), member->name);
 	if (member->size > 9999999999L)
-		ohshit(_("ar member size %jd too large"), member->size);
+		ohshit(_("ar member size %jd too large"), (intmax_t)member->size);
 
 	n = sprintf(header, "%-16s%-12lu%-6lu%-6lu%-8lo%-10jd`\n",
 	            member->name, (unsigned long)member->time,
diff --git a/lib/dpkg/t/c-tarextract.c b/lib/dpkg/t/c-tarextract.c
index fd47fdd..c235f44 100644
--- a/lib/dpkg/t/c-tarextract.c
+++ b/lib/dpkg/t/c-tarextract.c
@@ -23,6 +23,7 @@
 
 #include <sys/types.h>
 #include <fcntl.h>
+#include <stdint.h>
 #include <stdio.h>
 #include <stdlib.h>
 #include <unistd.h>
@@ -56,15 +57,15 @@ tar_object(void *ctx, struct tar_entry *te)
 	switch (te->type) {
 	case TAR_FILETYPE_FILE0:
 	case TAR_FILETYPE_FILE:
-		printf(" type=file size=%jd", te->size);
+		printf(" type=file size=%jd", (intmax_t)te->size);
 		break;
 	case TAR_FILETYPE_HARDLINK:
 		printf(" type=hardlink linkto=%s size=%jd",
-		       te->linkname, te->size);
+		       te->linkname, (intmax_t)te->size);
 		break;
 	case TAR_FILETYPE_SYMLINK:
 		printf(" type=symlink linkto=%s size=%jd",
-		       te->linkname, te->size);
+		       te->linkname, (intmax_t)te->size);
 		break;
 	case TAR_FILETYPE_DIR:
 		printf(" type=dir");
diff --git a/src/archives.c b/src/archives.c
index d07d4a4..71118ff 100644
--- a/src/archives.c
+++ b/src/archives.c
@@ -548,7 +548,7 @@ tarobject_matches(struct tarcontext *tc,
       ohshite(_("unable to read link '%.255s'"), fn_old);
     else if (linksize != stab->st_size)
       ohshit(_("symbolic link '%.250s' size has changed from %jd to %zd"),
-             fn_old, stab->st_size, linksize);
+             fn_old, (intmax_t)stab->st_size, linksize);
     linkname[linksize] = '\0';
     if (strcmp(linkname, te->linkname) == 0) {
       free(linkname);
@@ -1035,7 +1035,7 @@ tarobject(void *ctx, struct tar_entry *ti)
         ohshite(_("unable to read link '%.255s'"), ti->name);
       else if (r != stab.st_size)
         ohshit(_("symbolic link '%.250s' size has changed from %jd to %zd"),
-               fnamevb.buf, stab.st_size, r);
+               fnamevb.buf, (intmax_t)stab.st_size, r);
       varbuf_trunc(&symlinkfn, r);
       varbuf_end_str(&symlinkfn);
       if (symlink(symlinkfn.buf,fnametmpvb.buf))
diff --git a/src/configure.c b/src/configure.c
index 690a852..36b0430 100644
--- a/src/configure.c
+++ b/src/configure.c
@@ -38,6 +38,7 @@
 #include <dirent.h>
 #include <termios.h>
 #include <unistd.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <stdio.h>
 
@@ -759,7 +760,7 @@ conffderef(struct pkginfo *pkg, struct varbuf *result, const char *in)
 			} else if (r != stab.st_size) {
 				warning(_("symbolic link '%.250s' size has "
 				          "changed from %jd to %zd"),
-				        result->buf, stab.st_size, r);
+				        result->buf, (intmax_t)stab.st_size, r);
 				return -1;
 			}
 			varbuf_trunc(&target, r);

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git



More information about the Reproducible-commits mailing list