Skip to content

socketpair: fix compiler warning -Wunreachable-code - #23437

Closed
Vasiliy-Kkk wants to merge 2 commits into
curl:masterfrom
Vasiliy-Kkk:fix-unreachable-code
Closed

Vasiliy-Kkk wants to merge 2 commits into
curl:masterfrom
Vasiliy-Kkk:fix-unreachable-code

Conversation

@Vasiliy-Kkk

@Vasiliy-Kkk Vasiliy-Kkk commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor

Fixing:

lib/socketpair.c:75:6: error: code will never be executed [-Wunreachable-code]
   75 |   if(pipe(socks))
      |      ^~~~

Follow-up to c2a94ba #23126

@github-actions github-actions Bot added the name lookup DNS and related tech label Oct 16, 2026
@vszakats vszakats changed the title fix error: code will never be executed [-Werror,-Wunreachable-code] socketpair: fix compiler warning -Wunreachable-code Oct 16, 2026
@vszakats vszakats added build appleOS specific to an Apple operating system labels Oct 16, 2026
Comment thread lib/socketpair.c Resolved
@vszakats
vszakats requested a lite review from Copilot October 16, 2026 12:19

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Co-authored-by: Viktor Szakats <vszakats@users.noreply.github.com>
@vszakats

Copy link
Copy Markdown
Member

Can you post details about your config and toolchain? curious about how to reproduce.

@bagder
bagder requested a lite review from Copilot October 16, 2026 12:33
@vszakats vszakats self-assigned this Oct 16, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 Needs a closer look

The revised preprocessor structure still emits equivalent fallback code, so the warning is unresolved.

0 open findings

🧠 Review effort: Lite

@Vasiliy-Kkk

Vasiliy-Kkk commented Oct 16, 2026 •

Copy link
Copy Markdown
Contributor Author

OS FreeBSD-12:

cat /etc/os-release
NAME=FreeBSD
VERSION="12.4-RELEASE"
VERSION_ID="12.4"
ID=freebsd
ANSI_COLOR="0;31"
PRETTY_NAME="FreeBSD 12.4-RELEASE"
CPE_NAME="cpe:/o:freebsd:freebsd:12.4"
HOME_URL="https://FreeBSD.org/"
BUG_REPORT_URL="https://bugs.FreeBSD.org/"

configure flags:
cmake curl -B build -DCURL_ENABLE_SSL=OFF -DCMAKE_C_FLAGS="-Werror=unreachable-code"
build error:

[  5%] Building C object lib/CMakeFiles/libcurl_shared.dir/uint-bset.c.o
/root/curl/lib/socketpair.c:75:6: error: code will never be executed [-Werror,-Wunreachable-code]
  if(pipe(socks))
     ^~~~
1 error generated.
--- lib/CMakeFiles/libcurl_shared.dir/socketpair.c.o ---
*** [lib/CMakeFiles/libcurl_shared.dir/socketpair.c.o] Error code 1

compiler version:

cc -v
FreeBSD clang version 13.0.0 (git@github.com:llvm/llvm-project.git llvmorg-13.0.0-0-gd7b669b3a303)
Target: x86_64-unknown-freebsd12.4
Thread model: posix
InstalledDir: /usr/bin

@vszakats vszakats removed the appleOS specific to an Apple operating system label Oct 16, 2026
@vszakats

vszakats commented Oct 16, 2026 •

Copy link
Copy Markdown
Member

It needs a HAVE_EVENTFD=0 (on non-Apple and clang), that's why CI does not catch this.

@vszakats vszakats closed this in ee3c438 Oct 16, 2026
@vszakats

Copy link
Copy Markdown
Member

Thanks @Vasiliy-Kkk!

vszakats added a commit to vszakats/curl that referenced this pull request Nov 3, 2026
To avoid a static linkage issue when using SDK 27 while targeting old
macOS versions (such as macOS 12). Maybe something to revisit in the
future when we either understood how to supports this now cleanly, or
enough time has passed that support can be enabled without causing
fallouts in real-world senarios.

Reported-by: Dan Rosser
Fixes curl#23650
Follow-up to ee3c438 curl#23437
Follow-up to c2a94ba curl#23126
vszakats added a commit that referenced this pull request Nov 4, 2026
To avoid a static linkage issue when using SDK 27 while targeting old
macOS versions (such as macOS 12). Maybe something to revisit in the
future when we either understood how to support this cleanly, or enough
time has passed that support can be enabled without causing fallouts in
real-world senarios.

Reported-by: Dan Rosser
Closes #23650
Follow-up to ee3c438 #23437
Follow-up to c2a94ba #23126

Closes #23717
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

build name lookup DNS and related tech

Development

Successfully merging this pull request may close these issues.

3 participants