@@ -195,6 +195,19 @@ struct strbuf;
195195#define _NETBSD_SOURCE 1
196196#define _SGI_SOURCE 1
197197
198+ /*
199+ * UNUSED marks a function parameter that is always unused. It also
200+ * can be used to annotate a function, a variable, or a type that is
201+ * always unused.
202+ *
203+ * A callback interface may dictate that a function accepts a
204+ * parameter at that position, but the implementation of the function
205+ * may not need to use the parameter. In such a case, mark the parameter
206+ * with UNUSED.
207+ *
208+ * When a parameter may be used or unused, depending on conditional
209+ * compilation, consider using MAYBE_UNUSED instead.
210+ */
198211#if GIT_GNUC_PREREQ (4 , 5 )
199212#define UNUSED __attribute__((unused)) \
200213 __attribute__((deprecated ("parameter declared as UNUSED")))
@@ -649,6 +662,17 @@ static inline int git_has_dir_sep(const char *path)
649662#define RESULT_MUST_BE_USED
650663#endif
651664
665+ /*
666+ * MAYBE_UNUSED marks a function parameter that may be unused, but
667+ * whose use is not an error. It also can be used to annotate a
668+ * function, a variable, or a type that may be unused.
669+ *
670+ * Depending on a configuration, all uses of such a thing may become
671+ * #ifdef'ed away. Marking it with UNUSED would give a warning in a
672+ * compilation where it is indeed used, and not marking it at all
673+ * would give a warning in a compilation where it is unused. In such
674+ * a case, MAYBE_UNUSED is the appropriate annotation to use.
675+ */
652676#define MAYBE_UNUSED __attribute__((__unused__))
653677
654678#include "compat/bswap.h"
0 commit comments