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

guillem pushed a commit to branch master
in repository dpkg.

View the commit online:
https://git.dpkg.org/cgit/dpkg/dpkg.git/commit/?id=906b9e51ef673a14ecc18c0c9989464d4f2c5127

commit 906b9e51ef673a14ecc18c0c9989464d4f2c5127
Author: Guillem Jover <[email protected]>
AuthorDate: Sat May 23 05:23:26 2020 +0200

    dpkg-split: Switch part number variables from unsigned int to int
    
    This fixes a mismatch format specifier in printf() with the
    variables types. Remove now unnecessary casts. And adapts the strtol()
    calls to handle negative values which we were not handling before.
    
    Warned-by: cppcheck
---
 debian/changelog        |  1 +
 dpkg-split/dpkg-split.h |  2 +-
 dpkg-split/join.c       |  6 +++---
 dpkg-split/queue.c      | 11 +++++------
 4 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index eba46e497..b6fa5cc59 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -62,6 +62,7 @@ dpkg (1.20.1) UNRELEASED; urgency=medium
       Thanks to Johannes Schauer <[email protected]>.
   * Code internals:
     - Use $() in shell or qx() in perl instead of ``.
+    - dpkg-split: Switch part number variables from unsigned int to int.
   * Build system:
     - Handle .git being a plain file when getting the dpkg tree version.
     - Add debian/changelog as a Changes file to the CPAN distribution.
diff --git a/dpkg-split/dpkg-split.h b/dpkg-split/dpkg-split.h
index 3064d4d2e..f53e0c5a4 100644
--- a/dpkg-split/dpkg-split.h
+++ b/dpkg-split/dpkg-split.h
@@ -40,7 +40,7 @@ struct partinfo {
   const char *arch;
   const char *md5sum;
   off_t orglength;
-  unsigned int thispartn, maxpartn;
+  int thispartn, maxpartn;
   off_t maxpartlen;
   off_t thispartoffset;
   off_t thispartlen;
diff --git a/dpkg-split/join.c b/dpkg-split/join.c
index 40afb378e..51de444bc 100644
--- a/dpkg-split/join.c
+++ b/dpkg-split/join.c
@@ -39,7 +39,7 @@
 void reassemble(struct partinfo **partlist, const char *outputfile) {
   struct dpkg_error err;
   int fd_out, fd_in;
-  unsigned int i;
+  int i;
 
   printf(P_("Putting package %s together from %d part: ",
             "Putting package %s together from %d parts: ",
@@ -63,7 +63,7 @@ void reassemble(struct partinfo **partlist, const char 
*outputfile) {
              pi->filename, outputfile, err.str);
     close(fd_in);
 
-    printf("%u ", i + 1);
+    printf("%d ", i + 1);
   }
   if (fsync(fd_out))
     ohshite(_("unable to sync file '%s'"), outputfile);
@@ -103,7 +103,7 @@ do_join(const char *const *argv)
   struct partqueue *queue = NULL;
   struct partqueue *pq;
   struct partinfo *refi, **partlist;
-  unsigned int i;
+  int i;
 
   if (!*argv)
     badusage(_("--%s requires one or more part file arguments"),
diff --git a/dpkg-split/queue.c b/dpkg-split/queue.c
index 0e00af54f..5a08c16fd 100644
--- a/dpkg-split/queue.c
+++ b/dpkg-split/queue.c
@@ -73,12 +73,12 @@ decompose_filename(const char *filename, struct partqueue 
*pq)
 
   p = q;
   pq->info.thispartn = (int)strtol(p, &q, 16);
-  if (q == p || *q++ != '.' || errno != 0)
+  if (q == p || *q++ != '.' || pq->info.thispartn < 0 || errno != 0)
     return false;
 
   p = q;
   pq->info.maxpartn = (int)strtol(p, &q, 16);
-  if (q == p || *q || errno != 0)
+  if (q == p || *q || pq->info.maxpartn < 0 || errno != 0)
     return false;
 
   return true;
@@ -143,8 +143,7 @@ do_auto(const char *const *argv)
   struct partqueue *queue;
   struct partqueue *pq;
   struct dpkg_ar *part;
-  unsigned int i;
-  int j;
+  int i, j;
 
   if (!opt_outputfile)
     badusage(_("--auto requires the use of the --output option"));
@@ -226,7 +225,7 @@ do_auto(const char *const *argv)
     /* There are still some parts missing. */
     for (i=0, ap=0; i<refi->maxpartn; i++)
       if (!partlist[i])
-        printf("%s%d", !ap++ ? "" : i == (unsigned int)j ? _(" and ") : ", ", 
i + 1);
+        printf("%s%d", !ap++ ? "" : i == j ? _(" and ") : ", ", i + 1);
     printf(").\n");
 
     dir_sync_path(opt_depotdir);
@@ -282,7 +281,7 @@ do_queue(const char *const *argv)
   head= N_("Packages not yet reassembled:\n");
   for (pq= queue; pq; pq= pq->nextinqueue) {
     struct partinfo ti;
-    unsigned int i;
+    int i;
 
     if (!pq->info.md5sum) continue;
     mustgetpartinfo(pq->info.filename,&ti);

-- 
Dpkg.Org's dpkg

Reply via email to