]> git.ipfire.org Git - thirdparty/squid.git/commitdiff
ESI: Fix build [-Wsingle-bit-bitfield-constant-conversion] (#1432)
authorFrancesco Chemolli <5175948+kinkie@users.noreply.github.com>
Sat, 29 Jul 2023 08:41:53 +0000 (08:41 +0000)
committerSquid Anubis <squid-anubis@squid-cache.org>
Sat, 29 Jul 2023 14:58:48 +0000 (14:58 +0000)
clang 16, the default on current fedora rawhide and centos stream 9,
complains about several ESI places:

    error: implicit truncation from 'int' to a one-bit wide bit-field
    changes value from 1 to -1
    [-Werror,-Wsingle-bit-bitfield-constant-conversion]

Turn 1-bit flags in ESI data structures from ints to unsigned ints to
avoid the problem.

src/esi/Context.h
src/esi/Esi.cc
src/esi/Include.h
src/esi/Literal.h
src/esi/Sequence.h
src/esi/VarState.h

index 13c761803722d1c2d9719752a69f2a5b8966fa2f..fd44d863c2a35e4f7e3f255ba523c6799e10ea03 100644 (file)
@@ -75,20 +75,20 @@ public:
     ClientHttpRequest *http;
 
     struct {
-        int passthrough:1;
-        int oktosend:1;
-        int finished:1;
+        unsigned int passthrough:1;
+        unsigned int oktosend:1;
+        unsigned int finished:1;
 
         /* an error has occurred, send full body replies
          * regardless. Note that we don't fail midstream
          * because we buffer until we can not fail
          */
-        int error:1;
+        unsigned int error:1;
 
-        int finishedtemplate:1; /* we've read the entire template */
-        int clientwantsdata:1; /* we need to satisfy a read request */
-        int kicked:1; /* note on reentering the kick routine */
-        int detached:1; /* our downstream has detached */
+        unsigned int finishedtemplate:1; /* we've read the entire template */
+        unsigned int clientwantsdata:1; /* we need to satisfy a read request */
+        unsigned int kicked:1; /* note on reentering the kick routine */
+        unsigned int detached:1; /* our downstream has detached */
     } flags;
 
     err_type errorpage; /* if we error what page to use */
@@ -123,7 +123,7 @@ public:
         ParserState();
         void freeResources();
         void popAll();
-        int parsing:1; /* libexpat is not reentrant on the same context */
+        unsigned int parsing:1; /* libexpat is not reentrant on the same context */
 
     private:
         bool inited_;
index 122934ddca35ae36d4448b5164789ef8788ca4da..fc0443872bca5b5627dd84b189223102aea0f8ae 100644 (file)
@@ -141,10 +141,10 @@ public:
     ESIElement::Pointer except;
 
     struct {
-        int attemptok:1; /* the attempt branch process correctly */
-        int exceptok:1; /* likewise */
-        int attemptfailed:1; /* The attempt branch failed */
-        int exceptfailed:1; /* the except branch failed */
+        unsigned int attemptok:1; /* the attempt branch process correctly */
+        unsigned int exceptok:1; /* likewise */
+        unsigned int attemptfailed:1; /* The attempt branch failed */
+        unsigned int exceptfailed:1; /* the except branch failed */
     } flags;
     void finish() override;
 
index ff33b1a6c1888dee1d326d9c3f86bc54feda4ae3..d0dc527adeab64e57ab7023beeb56de18d9cfe98 100644 (file)
@@ -47,9 +47,9 @@ public:
     void subRequestDone (ESIStreamContext::Pointer, bool);
 
     struct {
-        int onerrorcontinue:1; /* on error return zero data */
-        int failed:1; /* Failed to process completely */
-        int finished:1; /* Finished getting subrequest data */
+        unsigned int onerrorcontinue:1; /* on error return zero data */
+        unsigned int failed:1; /* Failed to process completely */
+        unsigned int finished:1; /* Finished getting subrequest data */
     } flags;
     ESIStreamContext::Pointer src;
     ESIStreamContext::Pointer alt;
index 9f24adaef0a22a623221c0632a24d7c9fe7866e3..51968ce411293a6d4012fb3e28eb2daa56be0e42 100644 (file)
@@ -32,7 +32,7 @@ public:
     ESISegment::Pointer buffer;
 
     struct {
-        int donevars:1;
+        unsigned int donevars:1;
     } flags;
 
     ESIVarState *varState;
index 9efe15d1e4562c0356e14ba9c312915271597b93..eaffe7f77acce7cfa7e40b2619a5e41bb825eaf4 100644 (file)
@@ -40,7 +40,7 @@ public:
     size_t processedcount;
 
     struct {
-        int dovars:1; /* for esiVar */
+        unsigned int dovars:1; /* for esiVar */
     } flags;
     void finish() override;
 
index 8a3a87b5ba6982da83919cbf34f195130e0ffd5c..e4ae2e9bbce26428004faeb1fcb5dd0fb98344e5 100644 (file)
@@ -63,11 +63,11 @@ private:
     HttpHeader hdr;
 
     struct {
-        int language:1;
-        int cookie:1;
-        int host:1;
-        int referer:1;
-        int useragent:1;
+        unsigned int language:1;
+        unsigned int cookie:1;
+        unsigned int host:1;
+        unsigned int referer:1;
+        unsigned int useragent:1;
     } flags;
 
 public: