Browse Source

Cast off_t variables to intmax_t when printing them with %jd

Warned-by: clang
Guillem Jover 10 years ago
parent
commit
f10a135c0e
6 changed files with 12 additions and 8 deletions
  1. 2 0
      debian/changelog
  2. 1 1
      dpkg-deb/extract.c
  3. 1 1
      lib/dpkg/ar.c
  4. 4 3
      lib/dpkg/t/c-tarextract.c
  5. 2 2
      src/archives.c
  6. 2 1
      src/configure.c

+ 2 - 0
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

+ 1 - 1
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);
 

+ 1 - 1
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,

+ 4 - 3
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");

+ 2 - 2
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))

+ 2 - 1
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);