Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add function parameter prototypes for clang #424

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jailbird777
Copy link
Contributor

Modern clang (16+) requires all function prototypes to have arguments.

This affects the old K&R style in librb/src/crypt.c and the 'DCF' declaration

Modern clang (16+) requires all function prototypes to have arguments.

This affects the old K&R style in librb/src/crypt.c and the 'DCF' declaration
@@ -199,7 +199,7 @@ main(int argc, char *argv[])
rb_set_time();
setup_signals();

authd_option_handlers = rb_dictionary_create("authd options handlers", rb_strcasecmp);
authd_option_handlers = rb_dictionary_create("authd options handlers", (DCF)rb_strcasecmp);
Copy link
Contributor

Choose a reason for hiding this comment

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

Casting function pointers depends on the representation of const char * and const void * being the same, which is likely but not guaranteed. It would be safer to have wrappers (one for rb_strcasecmp and one for irccmp) that can be passed to rb_dictionary_create without a conversion.

Since rb_strcasecmp is part of librb, librb could also provide this wrapper. The wrapper for irccmp will need to be in ircd/.

By the way, the unsafety is similar to the previous unsafety since the code in librb/src/dictionary.c calls the unprototyped function with two const void * in all cases. The change to a prototyped function adds checking to those calls.

@@ -33,7 +33,7 @@

static void replace1(void)
{
rb_dictionary *dict = rb_dictionary_create("replace1", strcmp);
rb_dictionary *dict = rb_dictionary_create("replace1", (DCF)strcmp);
Copy link
Contributor

Choose a reason for hiding this comment

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

This strcmp also needs a wrapper somewhere to fix the types.

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