]> git.kaiwu.me - haproxy.git/commitdiff
CLEANUP: src/cpuset.c: fix missing return in functions returning int
authorIlia Shipitsin <chipitsine@gmail.com>
Sat, 25 Apr 2026 11:04:48 +0000 (13:04 +0200)
committerWilly Tarreau <w@1wt.eu>
Tue, 12 May 2026 06:55:19 +0000 (08:55 +0200)
Cppcheck found the issue described in github #2124, which can cause these
errors if no CPUSET implementation is supported (and CPUSET_USE_ULONG is
not enabled):

src/cpuset.c:21:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:36:11: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:100:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:124:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:152:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]
src/cpuset.c:163:1: error: Found an exit path from function with non-void return type that has missing return statement [missingReturn]

This can be backported.

src/cpuset.c

index f85c31b9c967dabff6cb18eadd1ade56ab354e9d..34dce9202ffd1a48042d1f3e2e319809930bb05c 100644 (file)
@@ -27,6 +27,8 @@ int ha_cpuset_set(struct hap_cpuset *set, int cpu)
 #elif defined(CPUSET_USE_ULONG)
        set->cpuset |= (0x1 << cpu);
        return 0;
+#else
+       return 1;
 #endif
 }
 
@@ -42,6 +44,8 @@ int ha_cpuset_clr(struct hap_cpuset *set, int cpu)
 #elif defined(CPUSET_USE_ULONG)
        set->cpuset &= ~(0x1 << cpu);
        return 0;
+#else
+       return 1;
 #endif
 }
 
@@ -96,6 +100,8 @@ int ha_cpuset_count(const struct hap_cpuset *set)
 
 #elif defined(CPUSET_USE_ULONG)
        return my_popcountl(set->cpuset);
+#else
+       return 0;
 #endif
 }
 
@@ -120,6 +126,8 @@ int ha_cpuset_ffs(const struct hap_cpuset *set)
                return 0;
 
        return my_ffsl(set->cpuset);
+#else
+       return 0;
 #endif
 }
 
@@ -148,6 +156,8 @@ int ha_cpuset_isequal(const struct hap_cpuset *dst, const struct hap_cpuset *src
 
 #elif defined(CPUSET_USE_ULONG)
        return dst->cpuset == src->cpuset;
+#else
+       return 0;
 #endif
 }
 
@@ -158,7 +168,8 @@ int ha_cpuset_size()
 
 #elif defined(CPUSET_USE_ULONG)
        return LONGBITS;
-
+#else
+       return 0;
 #endif
 }