Skip to content

compat: Add support for getprogname(3)#620

Merged
rsmarples merged 4 commits into
masterfrom
getprogname
Jun 2, 2026
Merged

compat: Add support for getprogname(3)#620
rsmarples merged 4 commits into
masterfrom
getprogname

Conversation

@rsmarples
Copy link
Copy Markdown
Member

@rsmarples rsmarples commented Jun 2, 2026

logerr and pidfile will use it commonly.

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Jun 2, 2026

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 494556ca-f9e9-4784-9549-4f35fe834561

📥 Commits

Reviewing files that changed from the base of the PR and between 20718c0 and 28858df.

📒 Files selected for processing (2)
  • compat/getprogname.c
  • compat/getprogname.h
🚧 Files skipped from review as they are similar to previous changes (2)
  • compat/getprogname.h
  • compat/getprogname.c

Walkthrough

Adds a compat implementation and header for getprogname/setprogname, updates configure to detect native support and enable the compat source when needed, and removes duplicate local implementations from setproctitle and logerr.

Changes

Centralize program name handling

Layer / File(s) Summary
Public header
compat/getprogname.h
Declares const char *getprogname(void) and void setprogname(const char *).
Compatibility implementation
compat/getprogname.c
Implements getprogname()/setprogname() with a single static cached pointer; getprogname() returns program_invocation_short_name when available, otherwise emits a compile-time warning and returns PACKAGE; setprogname() replaces the cached pointer.
Configure feature detection
configure
Adds compile/run tests for getprogname() and program_invocation_short_name; when native support is missing, adds compat/getprogname.c to COMPAT_SRCS and injects #include "compat/getprogname.h" into config.h; defines HAVE_PROGRAM_INVOCATION_SHORT_NAME when detected.
Remove duplicate/local implementations and wiring
compat/setproctitle.h, compat/setproctitle.c, src/logerr.c
Removes inline/local getprogname() helpers and their state; setproctitle_init() no longer duplicates/installs a program-name via setprogname(); logerr.c drops its Linux-specific helper and simplifies logclose() to only call closelog().

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 20.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title 'compat: Add support for getprogname(3)' clearly and concisely summarizes the main change: adding compatibility support for the getprogname function across multiple files and the build system.
Description check ✅ Passed The description 'logerr and pidfile will use it commonly' is related to the changeset, providing context for why this compatibility support is being added, though it is brief.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch getprogname

Warning

There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure.

🔧 Infer (1.2.0)
compat/getprogname.c

compat/getprogname.c:32:10: fatal error: 'config.h' file not found
32 | #include "config.h"
| ^~~~~~~~~~
1 error generated.
Error: the following clang command did not run successfully:
/opt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/bin/clang-18
@/tmp/coderabbit-infer/28858df26abbab08e0db7ba9d5234b5d0778e18e-c59e81b8099bc95b/tmp/clang_command_.tmp.3add5a.txt
++Contents of '/tmp/coderabbit-infer/28858df26abbab08e0db7ba9d5234b5d0778e18e-c59e81b8099bc95b/tmp/clang_command_.tmp.3add5a.txt':
"-cc1" "-load"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../../facebook-clang-plugins/libtooling/build/FacebookClangPlugin.dylib"
"-add-plugin" "BiniouASTExporter" "-plugin-arg-BiniouASTExporter" "-"
"-plugin-arg-BiniouASTExporter" "PREPEND_CURRENT_DIR=1"
"-plugin-arg-BiniouASTExporter" "MAX_STRING_SIZE=65535" "-cc1" "-triple"
"x86_64-unknown-linux-gnu" "-emit-obj" "-mrelax-all" "-disable-free"
"-clear-ast-be

... [truncated 683 characters] ...

pt/infer-linux-x86_64-v1.2.0/lib/infer/facebook-clang-plugins/clang/install/lib/clang/18/include"
"-internal-isystem" "/usr/local/include" "-internal-isystem"
"/usr/lib/gcc/x86_64-linux-gnu/12/../../../../x86_64-linux-gnu/include"
"-internal-externc-isystem" "/usr/include/x86_64-linux-gnu"
"-internal-externc-isystem" "/include" "-internal-externc-isystem"
"/usr/include" "-Wno-ignored-optimization-argument" "-Wno-everything"
"-ferror-limit" "19" "-fgnuc-version=4.2.1" "-fskip-odr-check-in-gmf"
"-D__GCC_HAVE_DWARF2_CFI_ASM=1" "-o"
"/tmp/coderabbit-infer/c59e81b8099bc95b/file.o" "-x" "c"
"compat/getprogname.c" "-O0" "-fno-builtin" "-include"
"/opt/infer-linux-x86_64-v1.2.0/lib/infer/infer/bin/../lib/clang_wrappers/global_defines.h"
"-Wno-everything"


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 2

🧹 Nitpick comments (1)
configure (1)

1078-1094: 💤 Low value

Variable name GETPROCNAME doesn't match the feature getprogname.

Every other feature gate uses the function name (STRLCPY, REALLOCARRAY, SETPROCTITLE, ...), but this one is GETPROCNAME (procname) while detecting getprogname (progname). An operator trying to pre-set the override via GETPROGNAME=... would be silently ignored. Consider renaming to GETPROGNAME for consistency.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@configure` around lines 1078 - 1094, The feature variable is misnamed: change
all uses of GETPROCNAME to GETPROGNAME so it matches the detected symbol
getprogname; update the initial test (the if [ -z "$GETPROCNAME" ] branch), the
assignment branches setting GETPROCNAME=yes/no, the echo/rm lines if needed, and
the later conditional if [ "$GETPROCNAME" = no ] to use GETPROGNAME instead,
ensuring the test wrapper file name (_getprogname.c) and function getprogname
remain unchanged so pre-set overrides via GETPROGNAME=... work correctly.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@compat/getprogname.c`:
- Around line 50-84: The getprogname() implementation must never return NULL;
change all paths that currently return NULL (calloc/readlink failures and the
progname[0] == '[' check) to return PACKAGE as a safe fallback, and ensure the
non-Linux `#else` branch returns progname if it was set by setprogname() (i.e., if
progname != NULL) otherwise PACKAGE so setprogname() actually takes effect;
update uses of progname, progname_free, progname_atexit, getprogname(), and
freeprogname() accordingly so callers always receive a valid C string.

In `@configure`:
- Line 1096: Remove the stray backslash after the quoted include in the echo
command that writes to CONFIG_H: the line that calls echo with the string
"`#include`			\"compat/getprogname.h\"" should not have a trailing backslash
before the redirect, so update the echo invocation that appends to CONFIG_H (the
echo ... >>$CONFIG_H line) to remove the backslash and match the other compat
blocks, ensuring no trailing whitespace is written.

---

Nitpick comments:
In `@configure`:
- Around line 1078-1094: The feature variable is misnamed: change all uses of
GETPROCNAME to GETPROGNAME so it matches the detected symbol getprogname; update
the initial test (the if [ -z "$GETPROCNAME" ] branch), the assignment branches
setting GETPROCNAME=yes/no, the echo/rm lines if needed, and the later
conditional if [ "$GETPROCNAME" = no ] to use GETPROGNAME instead, ensuring the
test wrapper file name (_getprogname.c) and function getprogname remain
unchanged so pre-set overrides via GETPROGNAME=... work correctly.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 55a2091f-3634-492f-971c-a94fc5affcad

📥 Commits

Reviewing files that changed from the base of the PR and between 082d1f2 and 113a825.

📒 Files selected for processing (6)
  • compat/getprogname.c
  • compat/getprogname.h
  • compat/setproctitle.c
  • compat/setproctitle.h
  • configure
  • src/logerr.c
💤 Files with no reviewable changes (1)
  • compat/setproctitle.h

Comment thread compat/getprogname.c
Comment thread configure Outdated
@rsmarples rsmarples merged commit 4bbe25e into master Jun 2, 2026
6 checks passed
@rsmarples rsmarples deleted the getprogname branch June 2, 2026 12:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant