Skip to content

Commit dad3549

Browse files
committed
remove __P() macro for C89/musl portability
The __P() macro was a K&R C compatibility shim that wrapped function prototypes so they compiled with both ANSI C and pre-ANSI compilers. All modern C compilers (and every platform that can run a mail server) have supported ANSI C for decades. musl libc does not define __P(), so the macro causes build failures on Alpine Linux and similar musl-based systems. Remove all __P() uses and the ifdef __STDC__ define blocks that introduced them. Fixes #140
1 parent fc78c00 commit dad3549

36 files changed

Lines changed: 510 additions & 582 deletions

libopendkim/dkim-atps.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#endif /* USE_GNUTLS */
4040

4141
/* prototypes */
42-
extern void dkim_error __P((DKIM *, const char *, ...));
42+
extern void dkim_error (DKIM *, const char *, ...);
4343

4444
/* local definitions needed for DNS queries */
4545
#define MAXPACKET 8192

libopendkim/dkim-cache.h

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -19,13 +19,13 @@
1919
#include <db.h>
2020

2121
/* prototypes */
22-
extern void dkim_cache_close __P((DB *));
23-
extern int dkim_cache_expire __P((DB *, int, int *));
24-
extern DB *dkim_cache_init __P((int *, char *));
25-
extern int dkim_cache_insert __P((DB *, char *, char *, int, int *));
26-
extern int dkim_cache_query __P((DB *, char *, int, char *, size_t *, int *));
27-
extern void dkim_cache_stats __P((DB *, u_int *, u_int *, u_int *, u_int *,
28-
_Bool));
22+
extern void dkim_cache_close (DB *);
23+
extern int dkim_cache_expire (DB *, int, int *);
24+
extern DB *dkim_cache_init (int *, char *);
25+
extern int dkim_cache_insert (DB *, char *, char *, int, int *);
26+
extern int dkim_cache_query (DB *, char *, int, char *, size_t *, int *);
27+
extern void dkim_cache_stats (DB *, u_int *, u_int *, u_int *, u_int *,
28+
_Bool);
2929

3030
#endif /* QUERY_CACHE */
3131

libopendkim/dkim-canon.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
#define DKIM_ISLWSP(x) ((x) == 011 || (x) == 012 || (x) == 015 || (x) == 040)
6565

6666
/* prototypes */
67-
extern void dkim_error __P((DKIM *, const char *, ...));
67+
extern void dkim_error (DKIM *, const char *, ...);
6868

6969
/* ========================= PRIVATE SECTION ========================= */
7070

libopendkim/dkim-canon.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -23,23 +23,23 @@
2323
#define DKIM_HASHBUFSIZE 4096
2424

2525
/* prototypes */
26-
extern DKIM_STAT dkim_add_canon __P((DKIM *, _Bool, dkim_canon_t, int,
26+
extern DKIM_STAT dkim_add_canon (DKIM *, _Bool, dkim_canon_t, int,
2727
u_char *, struct dkim_header *,
28-
ssize_t length, DKIM_CANON **));
29-
extern DKIM_STAT dkim_canon_bodychunk __P((DKIM *, u_char *, size_t));
30-
extern void dkim_canon_cleanup __P((DKIM *));
31-
extern DKIM_STAT dkim_canon_closebody __P((DKIM *));
32-
extern DKIM_STAT dkim_canon_getfinal __P((DKIM_CANON *, u_char **, size_t *));
33-
extern DKIM_STAT dkim_canon_gethashes __P((DKIM_SIGINFO *, void **, size_t *,
34-
void **, size_t *));
35-
extern DKIM_STAT dkim_canon_header_string __P((struct dkim_dstring *,
28+
ssize_t length, DKIM_CANON **);
29+
extern DKIM_STAT dkim_canon_bodychunk (DKIM *, u_char *, size_t);
30+
extern void dkim_canon_cleanup (DKIM *);
31+
extern DKIM_STAT dkim_canon_closebody (DKIM *);
32+
extern DKIM_STAT dkim_canon_getfinal (DKIM_CANON *, u_char **, size_t *);
33+
extern DKIM_STAT dkim_canon_gethashes (DKIM_SIGINFO *, void **, size_t *,
34+
void **, size_t *);
35+
extern DKIM_STAT dkim_canon_header_string (struct dkim_dstring *,
3636
dkim_canon_t, unsigned char *,
37-
size_t, _Bool));
38-
extern DKIM_STAT dkim_canon_init __P((DKIM *, _Bool, _Bool));
39-
extern u_long dkim_canon_minbody __P((DKIM *));
40-
extern DKIM_STAT dkim_canon_runheaders __P((DKIM *));
41-
extern int dkim_canon_selecthdrs __P((DKIM *, u_char *, struct dkim_header **,
42-
int));
43-
extern DKIM_STAT dkim_canon_signature __P((DKIM *, struct dkim_header *));
37+
size_t, _Bool);
38+
extern DKIM_STAT dkim_canon_init (DKIM *, _Bool, _Bool);
39+
extern u_long dkim_canon_minbody (DKIM *);
40+
extern DKIM_STAT dkim_canon_runheaders (DKIM *);
41+
extern int dkim_canon_selecthdrs (DKIM *, u_char *, struct dkim_header **,
42+
int);
43+
extern DKIM_STAT dkim_canon_signature (DKIM *, struct dkim_header *);
4444

4545
#endif /* ! _DKIM_CANON_H_ */

libopendkim/dkim-dns.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@
1010
#include "dkim.h"
1111

1212
/* prototypes */
13-
extern int dkim_res_cancel __P((void *, void *));
14-
extern void dkim_res_close __P((void *));
15-
extern int dkim_res_init __P((void **));
16-
extern int dkim_res_nslist __P((void *, const char *));
17-
extern int dkim_res_query __P((void *, int, unsigned char *, unsigned char *,
18-
size_t, void **));
19-
extern int dkim_res_waitreply __P((void *, void *, struct timeval *,
20-
size_t *, int *, int *));
13+
extern int dkim_res_cancel (void *, void *);
14+
extern void dkim_res_close (void *);
15+
extern int dkim_res_init (void **);
16+
extern int dkim_res_nslist (void *, const char *);
17+
extern int dkim_res_query (void *, int, unsigned char *, unsigned char *,
18+
size_t, void **);
19+
extern int dkim_res_waitreply (void *, void *, struct timeval *,
20+
size_t *, int *, int *);
2121

2222
#endif /* ! _DKIM_DNS_H_ */

libopendkim/dkim-internal.h

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,6 @@
3737
# define MAX(x,y) ((x) > (y) ? (x) : (y))
3838
#endif /* ! MAX */
3939

40-
#ifdef __STDC__
41-
# ifndef __P
42-
# define __P(x) x
43-
# endif /* ! __P */
44-
#else /* __STDC__ */
45-
# ifndef __P
46-
# define __P(x) ()
47-
# endif /* ! __P */
48-
#endif /* __STDC__ */
4940

5041
/* limits, macros, etc. */
5142
#define BUFRSZ 1024 /* base temp buffer size */
@@ -170,8 +161,8 @@ extern DKIM_NAMETABLE *dkim_table_mandatory;
170161
#endif /* _FFR_CONDITIONAL */
171162

172163
/* prototypes */
173-
extern DKIM_STAT dkim_process_set __P((DKIM *, dkim_set_t, u_char *, size_t,
174-
void *, _Bool, const char *));
175-
extern DKIM_STAT dkim_siglist_setup __P((DKIM *));
164+
extern DKIM_STAT dkim_process_set (DKIM *, dkim_set_t, u_char *, size_t,
165+
void *, _Bool, const char *);
166+
extern DKIM_STAT dkim_siglist_setup (DKIM *);
176167

177168
#endif /* ! _DKIM_INTERNAL_H_ */

libopendkim/dkim-keys.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
#endif /* USE_STRL_H */
4141

4242
/* prototypes */
43-
extern void dkim_error __P((DKIM *, const char *, ...));
43+
extern void dkim_error (DKIM *, const char *, ...);
4444

4545
/* local definitions needed for DNS queries */
4646
#define MAXPACKET 8192

libopendkim/dkim-keys.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@
1212
#include "dkim.h"
1313

1414
/* prototypes */
15-
extern DKIM_STAT dkim_get_key_dns __P((DKIM *, DKIM_SIGINFO *, u_char *,
16-
size_t));
17-
extern DKIM_STAT dkim_get_key_file __P((DKIM *, DKIM_SIGINFO *, u_char *,
18-
size_t));
15+
extern DKIM_STAT dkim_get_key_dns (DKIM *, DKIM_SIGINFO *, u_char *,
16+
size_t);
17+
extern DKIM_STAT dkim_get_key_file (DKIM *, DKIM_SIGINFO *, u_char *,
18+
size_t);
1919

2020
#endif /* ! _DKIM_KEYS_H_ */

libopendkim/dkim-mailparse.h

Lines changed: 4 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,20 +9,11 @@
99
#ifndef _DKIM_MAILPARSE_H_
1010
#define _DKIM_MAILPARSE_H_
1111

12-
#ifdef __STDC__
13-
# ifndef __P
14-
# define __P(x) x
15-
# endif /* ! __P */
16-
#else /* __STDC__ */
17-
# ifndef __P
18-
# define __P(x) ()
19-
# endif /* ! __P */
20-
#endif /* __STDC__ */
2112

2213
/* prototypes */
23-
extern int dkim_mail_parse __P((unsigned char *line, unsigned char **user_out,
24-
unsigned char **domain_out));
25-
extern int dkim_mail_parse_multi __P((unsigned char *line,
14+
extern int dkim_mail_parse (unsigned char *line, unsigned char **user_out,
15+
unsigned char **domain_out);
16+
extern int dkim_mail_parse_multi (unsigned char *line,
2617
unsigned char ***users_out,
27-
unsigned char ***domains_out));
18+
unsigned char ***domains_out);
2819
#endif /* ! _DKIM_MAILPARSE_H_ */

libopendkim/dkim-report.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
#include "util.h"
2626

2727
/* prototypes */
28-
extern void dkim_error __P((DKIM *, const char *, ...));
28+
extern void dkim_error (DKIM *, const char *, ...);
2929

3030
/* local definitions needed for DNS queries */
3131
#define MAXPACKET 8192

0 commit comments

Comments
 (0)