Skip to content

Commit c2b8e54

Browse files
committed
Merge branch 'jc/noop-withstatic-inline' into seen
A no-op replacement function implemented as a C preprocessor macro does not perform as good a job as one implemented as a "static inline" function in catching errors in parameters; replace the former with the latter in <git-compat-util.h> header. * jc/noop-withstatic-inline: compat-util: type-check parameters of no-op replacement functions
2 parents 55f657e + 15b52a4 commit c2b8e54

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

git-compat-util.h

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -252,8 +252,10 @@ typedef unsigned long uintptr_t;
252252
#ifdef PRECOMPOSE_UNICODE
253253
#include "compat/precompose_utf8.h"
254254
#else
255-
#define precompose_str(in,i_nfd2nfc)
256-
#define precompose_argv(c,v)
255+
static inline void precompose_argv(int argc, const char **argv)
256+
{
257+
; /* nothing */
258+
}
257259
#define probe_utf8_pathname_composition()
258260
#endif
259261

@@ -270,7 +272,9 @@ struct itimerval {
270272
#endif
271273

272274
#ifdef NO_SETITIMER
273-
#define setitimer(which,value,ovalue)
275+
static inline int setitimer(int which, const struct itimerval *value, struct itimerval *newvalue) {
276+
; /* nothing */
277+
}
274278
#endif
275279

276280
#ifndef NO_LIBGEN_H
@@ -1231,8 +1235,14 @@ int warn_on_fopen_errors(const char *path);
12311235
#endif
12321236

12331237
#ifndef _POSIX_THREAD_SAFE_FUNCTIONS
1234-
#define flockfile(fh)
1235-
#define funlockfile(fh)
1238+
static inline void flockfile(FILE *fh)
1239+
{
1240+
; /* nothing */
1241+
}
1242+
static inline void funlockfile(FILE *fh)
1243+
{
1244+
; /* nothing */
1245+
}
12361246
#define getc_unlocked(fh) getc(fh)
12371247
#endif
12381248

0 commit comments

Comments
 (0)