1
0
mirror of https://github.com/git/git synced 2024-07-07 19:39:27 +00:00

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
This commit is contained in:
Junio C Hamano 2018-07-24 14:50:47 -07:00
commit 00da9b2091
7 changed files with 26 additions and 12 deletions

View File

@ -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)

View File

@ -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] : ' '),

2
path.h
View File

@ -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.
*/

View File

@ -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

View File

@ -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.

View File

@ -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,

8
utf8.c
View File

@ -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)
{