Skip to content

Fix function prototype declarations for cross-platform compatibility#54

Merged
thiagoralves merged 1 commit into
developmentfrom
devin/1766689628-fix-close-unix-socket-signature
Dec 25, 2025
Merged

Fix function prototype declarations for cross-platform compatibility#54
thiagoralves merged 1 commit into
developmentfrom
devin/1766689628-fix-close-unix-socket-signature

Conversation

@devin-ai-integration

Copy link
Copy Markdown
Contributor

Summary

Fixes a compilation error that occurs on some Linux distros with stricter compilers:

error: too many arguments to function 'close_unix_socket'; expected 0, have 1
error: conflicting types for 'close_unix_socket'; have 'void(int)'

The root cause was close_unix_socket() being declared with no parameters in the header but defined with int server_fd in the implementation. This PR fixes that mismatch and proactively updates other function declarations from () to (void) for C standards compliance.

Changes:

  • Fix close_unix_socket signature mismatch in unix_socket.h
  • Update empty () declarations to (void) in headers and definitions for: setup_unix_socket, watchdog_init, scan_cycle_time_start, scan_cycle_time_end
  • Update function pointer typedefs in plugin_driver.h to use (void)
  • Make store_on_buffer and retrieve_from_buffer static in log.c (internal functions)

Verified build passes with strict compiler flags: -Wall -Wextra -Werror -Wstrict-prototypes -Wold-style-definition

Review & Testing Checklist for Human

  • Verify close_unix_socket(int server_fd) signature in header matches the implementation (line 10 of unix_socket.h)
  • Test compilation on the distro that was originally failing (the one that reported the error)
  • If native plugins are in use, verify they still work after the function pointer typedef changes in plugin_driver.h

Recommended test plan: Build and run the PLC runtime on the distro that was originally failing to confirm the compilation error is resolved.

Notes

Link to Devin run: https://app.devin.ai/sessions/6bc2817257fc4494aaa3e09ad67875f2
Requested by: Thiago Alves (@thiagoralves)

- Fix close_unix_socket() signature mismatch: header declared with no
  parameters but implementation took int server_fd parameter
- Update empty () declarations to (void) in headers and definitions for
  C standards compliance:
  - setup_unix_socket()
  - watchdog_init()
  - scan_cycle_time_start()
  - scan_cycle_time_end()
- Update function pointer typedefs in plugin_driver.h to use (void)
- Make store_on_buffer and retrieve_from_buffer static in log.c

These changes ensure the code compiles on stricter compilers that treat
-Wstrict-prototypes and -Wold-style-definition as errors.

Co-Authored-By: Thiago Alves <thiagoralves@gmail.com>
@devin-ai-integration

Copy link
Copy Markdown
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

@thiagoralves thiagoralves requested a review from Copilot December 25, 2025 19:41

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull request overview

This PR addresses compilation errors on strict C compilers by fixing function prototype mismatches and standardizing empty parameter lists to use (void) instead of () for C standards compliance.

Key changes:

  • Fixed close_unix_socket signature mismatch between header declaration and implementation
  • Updated all empty parameter list declarations from () to (void) across headers and implementations
  • Made internal logging buffer functions static to improve encapsulation

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
core/src/plc_app/utils/watchdog.h Updated watchdog_init declaration to use (void)
core/src/plc_app/utils/watchdog.c Updated watchdog_init definition to use (void) and reordered includes alphabetically
core/src/plc_app/utils/log.c Made store_on_buffer and retrieve_from_buffer static, updated retrieve_from_buffer to use (void), and reformatted long lines
core/src/plc_app/unix_socket.h Fixed close_unix_socket signature to accept int server_fd parameter and updated setup_unix_socket to use (void)
core/src/plc_app/unix_socket.c Updated setup_unix_socket definition to use (void)
core/src/plc_app/scan_cycle_manager.h Updated scan_cycle_time_start and scan_cycle_time_end declarations to use (void)
core/src/plc_app/scan_cycle_manager.c Updated scan_cycle_time_start and scan_cycle_time_end definitions to use (void)
core/src/drivers/plugin_driver.h Updated function pointer typedefs to use (void) for empty parameter lists

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@thiagoralves thiagoralves merged commit 6d51d69 into development Dec 25, 2025
1 check passed
@thiagoralves thiagoralves deleted the devin/1766689628-fix-close-unix-socket-signature branch December 25, 2025 19:42
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.

2 participants