Bug 1639033 - Use the jarType enum type, not int, for certain variables and arguments in jar.c -- for greater precision, and to avoid sign-comparison warnings. r=kjacobs
authorJeff Walden <jwalden@mit.edu>
Fri, 22 May 2020 20:35:53 +0000
changeset 15625 e65dd5c2cf86c36d414fa99986e49e9b1bd97aa0
parent 15624 6512178a58f5108488feda1da805afa6a1ab6315
child 15626 a5f80d0805caeda11968611221ffd48f62334680
push id3751
push userkjacobs@mozilla.com
push dateFri, 22 May 2020 20:56:57 +0000
reviewerskjacobs
bugs1639033
Bug 1639033 - Use the jarType enum type, not int, for certain variables and arguments in jar.c -- for greater precision, and to avoid sign-comparison warnings. r=kjacobs Depends on D75841 Differential Revision: https://phabricator.services.mozilla.com/D75842
lib/jar/jar.c
--- a/lib/jar/jar.c
+++ b/lib/jar/jar.c
@@ -13,17 +13,17 @@
 #include "jar.h"
 #include "jarint.h"
 #include "portreg.h"
 
 static void
 jar_destroy_list(ZZList *list);
 
 static int
-jar_find_first_cert(JAR_Signer *signer, int type, JAR_Item **it);
+jar_find_first_cert(JAR_Signer *signer, jarType type, JAR_Item **it);
 
 /*
  *  J A R _ n e w
  *
  *  Create a new instantiation of a manifest representation.
  *  Use this as a token to any calls to this API.
  *
  */
@@ -318,17 +318,17 @@ JAR_find_end(JAR_Context *ctx)
  *
  */
 
 int
 JAR_find_next(JAR_Context *ctx, JAR_Item **it)
 {
     JAR *jar;
     ZZList *list = NULL;
-    int finding;
+    jarType finding;
     JAR_Signer *signer = NULL;
 
     PORT_Assert(ctx != NULL);
     PORT_Assert(ctx->jar != NULL);
 
     jar = ctx->jar;
 
     /* Internally, convert jarTypeSign to jarTypeSF, and return
@@ -408,16 +408,23 @@ JAR_find_next(JAR_Context *ctx, JAR_Item
             switch (finding) {
                 case jarTypeSF:
                     ctx->next = ZZ_ListHead(signer->sf);
                     break;
 
                 case jarTypeSign:
                     ctx->next = ZZ_ListHead(signer->certs);
                     break;
+
+                case jarTypeMF:
+                case jarTypeMeta:
+                case jarTypePhy:
+                case jarTypeSect:
+                case jarTypeOwner:
+                    break;
             }
         }
         PORT_Assert(ctx->next != NULL);
         if (ctx->next == NULL) {
             *it = NULL;
             return -1;
         }
         while (!ZZ_ListIterDone(list, ctx->next)) {
@@ -442,17 +449,17 @@ JAR_find_next(JAR_Context *ctx, JAR_Item
                 continue;
             }
             return 0;
         }
     } /* end while */
 }
 
 static int
-jar_find_first_cert(JAR_Signer *signer, int type, JAR_Item **it)
+jar_find_first_cert(JAR_Signer *signer, jarType type, JAR_Item **it)
 {
     ZZLink *link;
     ZZList *list = signer->certs;
     int status = JAR_ERR_PNF;
 
     *it = NULL;
     if (ZZ_ListEmpty(list)) {
         /* empty list */