diff options
author | Junio C Hamano <gitster@pobox.com> | 2018-07-24 14:50:47 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2018-07-24 14:50:47 -0700 |
commit | 00da9b2091ef8d1955fa2f021b8ba111ce6a5fed (patch) | |
tree | 6f06221912c327a5e92ccee1c8ecd0b3bfdd8459 | |
parent | Merge branch 'tb/config-default' (diff) | |
parent | utf8.c: avoid char overflow (diff) | |
download | tgif-00da9b2091ef8d1955fa2f021b8ba111ce6a5fed.tar.xz |
Merge branch 'bb/pedantic'
The codebase has been updated to compile cleanly with -pedantic
option.
* bb/pedantic:
utf8.c: avoid char overflow
string-list.c: avoid conversion from void * to function pointer
sequencer.c: avoid empty statements at top level
convert.c: replace "\e" escapes with "\033".
fixup! refs/refs-internal.h: avoid forward declaration of an enum
refs/refs-internal.h: avoid forward declaration of an enum
fixup! connect.h: avoid forward declaration of an enum
connect.h: avoid forward declaration of an enum
-rw-r--r-- | connect.h | 2 | ||||
-rw-r--r-- | convert.c | 2 | ||||
-rw-r--r-- | path.h | 2 | ||||
-rw-r--r-- | refs/refs-internal.h | 2 | ||||
-rw-r--r-- | sequencer.c | 4 | ||||
-rw-r--r-- | string-list.c | 18 | ||||
-rw-r--r-- | utf8.c | 8 |
7 files changed, 26 insertions, 12 deletions
@@ -1,6 +1,8 @@ #ifndef CONNECT_H #define CONNECT_H +#include "protocol.h" + #define CONNECT_VERBOSE (1u << 0) #define CONNECT_DIAG_URL (1u << 1) #define CONNECT_IPV4 (1u << 2) @@ -335,7 +335,7 @@ static void trace_encoding(const char *context, const char *path, strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding); for (i = 0; i < len && buf; ++i) { strbuf_addf( - &trace,"| \e[2m%2i:\e[0m %2x \e[2m%c\e[0m%c", + &trace, "| \033[2m%2i:\033[0m %2x \033[2m%c\033[0m%c", i, (unsigned char) buf[i], (buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '), @@ -147,7 +147,7 @@ extern void report_linked_checkout_garbage(void); /* * You can define a static memoized git path like: * - * static GIT_PATH_FUNC(git_path_foo, "FOO"); + * static GIT_PATH_FUNC(git_path_foo, "FOO") * * or use one of the global ones below. */ diff --git a/refs/refs-internal.h b/refs/refs-internal.h index dd834314bd..54bde5089a 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -1,6 +1,8 @@ #ifndef REFS_REFS_INTERNAL_H #define REFS_REFS_INTERNAL_H +#include "iterator.h" + /* * Data structures and functions for the internal use of the refs * module. Code outside of the refs module should use only the public diff --git a/sequencer.c b/sequencer.c index 03c47405fb..349ae04ffd 100644 --- a/sequencer.c +++ b/sequencer.c @@ -63,12 +63,12 @@ static GIT_PATH_FUNC(rebase_path_done, "rebase-merge/done") * The file to keep track of how many commands were already processed (e.g. * for the prompt). */ -static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum"); +static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum") /* * The file to keep track of how many commands are to be processed in total * (e.g. for the prompt). */ -static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end"); +static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end") /* * The commit message that is planned to be used for any changes that * need to be committed following a user interaction. diff --git a/string-list.c b/string-list.c index a0cf0cfe88..771c455098 100644 --- a/string-list.c +++ b/string-list.c @@ -224,18 +224,28 @@ struct string_list_item *string_list_append(struct string_list *list, list->strdup_strings ? xstrdup(string) : (char *)string); } +/* + * Encapsulate the compare function pointer because ISO C99 forbids + * casting from void * to a function pointer and vice versa. + */ +struct string_list_sort_ctx +{ + compare_strings_fn cmp; +}; + static int cmp_items(const void *a, const void *b, void *ctx) { - compare_strings_fn cmp = ctx; + struct string_list_sort_ctx *sort_ctx = ctx; const struct string_list_item *one = a; const struct string_list_item *two = b; - return cmp(one->string, two->string); + return sort_ctx->cmp(one->string, two->string); } void string_list_sort(struct string_list *list) { - QSORT_S(list->items, list->nr, cmp_items, - list->cmp ? list->cmp : strcmp); + struct string_list_sort_ctx sort_ctx = {list->cmp ? list->cmp : strcmp}; + + QSORT_S(list->items, list->nr, cmp_items, &sort_ctx); } struct string_list_item *unsorted_string_list_lookup(struct string_list *list, @@ -566,10 +566,10 @@ static int has_bom_prefix(const char *data, size_t len, return data && bom && (len >= bom_len) && !memcmp(data, bom, bom_len); } -static const char utf16_be_bom[] = {0xFE, 0xFF}; -static const char utf16_le_bom[] = {0xFF, 0xFE}; -static const char utf32_be_bom[] = {0x00, 0x00, 0xFE, 0xFF}; -static const char utf32_le_bom[] = {0xFF, 0xFE, 0x00, 0x00}; +static const char utf16_be_bom[] = {'\xFE', '\xFF'}; +static const char utf16_le_bom[] = {'\xFF', '\xFE'}; +static const char utf32_be_bom[] = {'\0', '\0', '\xFE', '\xFF'}; +static const char utf32_le_bom[] = {'\xFF', '\xFE', '\0', '\0'}; int has_prohibited_utf_bom(const char *enc, const char *data, size_t len) { |