← Commit list

d3dc5dbc87

Viktor Szakats
Viktor Szakats
2026-04-07
SUCCESS Duration: 250s

Subject

clang-tidy: avoid assigments in `if` expressions

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

.clang-tidy.yml+1 -0
@@ -13,6 +13,7 @@ Checks:
- -clang-analyzer-security.insecureAPI.DeprecatedOrUnsafeBufferHandling
- -clang-diagnostic-nullability-extension
- bugprone-assert-side-effect
+ - bugprone-assignment-in-if-condition
- bugprone-chained-comparison
- bugprone-dynamic-static-initializers
- bugprone-macro-parentheses
lib/vtls/gtls.c+9 -4
@@ -203,10 +203,15 @@ static gnutls_datum_t load_file(const char *file)
f = curlx_fopen(file, "rb");
if(!f)
return loaded_file;
- if(fseek(f, 0, SEEK_END) != 0 ||
- (filelen = ftell(f)) < 0 ||
- fseek(f, 0, SEEK_SET) != 0 ||
- !(ptr = curlx_malloc((size_t)filelen)))
+ if(fseek(f, 0, SEEK_END) != 0)
+ goto out;
+ filelen = ftell(f);
+ if(filelen < 0)
+ goto out;
+ if(fseek(f, 0, SEEK_SET) != 0)
+ goto out;
+ ptr = curlx_malloc((size_t)filelen);
+ if(!ptr)
goto out;
if(fread(ptr, 1, (size_t)filelen, f) < (size_t)filelen) {
curlx_free(ptr);
lib/vtls/x509asn1.c+27 -24
@@ -160,32 +160,35 @@ static const char *getASN1Element_(struct Curl_asn1Element *elem,
b = (unsigned char)*beg++;
if(!(b & 0x80))
len = b;
- else if(!(b &= 0x7F)) {
- /* Unspecified length. Since we have all the data, we can determine the
- effective length by skipping element until an end element is found. */
- if(!elem->constructed)
- return NULL;
- elem->beg = beg;
- while(beg < end && *beg) {
- beg = getASN1Element_(&lelem, beg, end, lvl + 1);
- if(!beg)
+ else {
+ b &= 0x7F;
+ if(!b) {
+ /* Unspecified length. Since we have all the data, we can determine the
+ effective length by skipping element until an end element is found. */
+ if(!elem->constructed)
+ return NULL;
+ elem->beg = beg;
+ while(beg < end && *beg) {
+ beg = getASN1Element_(&lelem, beg, end, lvl + 1);
+ if(!beg)
+ return NULL;
+ }
+ if(beg >= end)
return NULL;
+ elem->end = beg;
+ return beg + 1;
+ }
+ else if((unsigned)b > (size_t)(end - beg))
+ return NULL; /* Does not fit in source. */
+ else {
+ /* Get long length. */
+ len = 0;
+ do {
+ if(len & 0xFF000000L)
+ return NULL; /* Lengths > 32 bits are not supported. */
+ len = (len << 8) | (unsigned char) *beg++;
+ } while(--b);
}
- if(beg >= end)
- return NULL;
- elem->end = beg;
- return beg + 1;
- }
- else if((unsigned)b > (size_t)(end - beg))
- return NULL; /* Does not fit in source. */
- else {
- /* Get long length. */
- len = 0;
- do {
- if(len & 0xFF000000L)
- return NULL; /* Lengths > 32 bits are not supported. */
- len = (len << 8) | (unsigned char) *beg++;
- } while(--b);
}
if(len > (size_t)(end - beg))
return NULL; /* Element data does not fit in source. */