Skip to content

Merge bb/pedantic #1788

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 8 commits into from
Aug 9, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions connect.h
Original file line number Diff line number Diff line change
@@ -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)
Expand Down
2 changes: 1 addition & 1 deletion convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,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] : ' '),
Expand Down
2 changes: 1 addition & 1 deletion path.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down
2 changes: 2 additions & 0 deletions refs/refs-internal.h
Original file line number Diff line number Diff line change
@@ -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
Expand Down
4 changes: 2 additions & 2 deletions sequencer.c
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,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.
Expand Down
18 changes: 14 additions & 4 deletions string-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
8 changes: 4 additions & 4 deletions utf8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down