Skip to content

Commit 070e699

Browse files
authored
Merge pull request git-for-windows#1788 from gitster/bb/pedantic
Merge bb/pedantic to fix MSVC compile warnings
2 parents ede0edb + 2b647a0 commit 070e699

File tree

7 files changed

+26
-12
lines changed

7 files changed

+26
-12
lines changed

connect.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef CONNECT_H
22
#define CONNECT_H
33

4+
#include "protocol.h"
5+
46
#define CONNECT_VERBOSE (1u << 0)
57
#define CONNECT_DIAG_URL (1u << 1)
68
#define CONNECT_IPV4 (1u << 2)

convert.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ static void trace_encoding(const char *context, const char *path,
334334
strbuf_addf(&trace, "%s (%s, considered %s):\n", context, path, encoding);
335335
for (i = 0; i < len && buf; ++i) {
336336
strbuf_addf(
337-
&trace,"| \e[2m%2i:\e[0m %2x \e[2m%c\e[0m%c",
337+
&trace, "| \033[2m%2i:\033[0m %2x \033[2m%c\033[0m%c",
338338
i,
339339
(unsigned char) buf[i],
340340
(buf[i] > 32 && buf[i] < 127 ? buf[i] : ' '),

path.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ extern void report_linked_checkout_garbage(void);
147147
/*
148148
* You can define a static memoized git path like:
149149
*
150-
* static GIT_PATH_FUNC(git_path_foo, "FOO");
150+
* static GIT_PATH_FUNC(git_path_foo, "FOO")
151151
*
152152
* or use one of the global ones below.
153153
*/

refs/refs-internal.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
#ifndef REFS_REFS_INTERNAL_H
22
#define REFS_REFS_INTERNAL_H
33

4+
#include "iterator.h"
5+
46
/*
57
* Data structures and functions for the internal use of the refs
68
* module. Code outside of the refs module should use only the public

sequencer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,12 +61,12 @@ static GIT_PATH_FUNC(rebase_path_done, "rebase-merge/done")
6161
* The file to keep track of how many commands were already processed (e.g.
6262
* for the prompt).
6363
*/
64-
static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum");
64+
static GIT_PATH_FUNC(rebase_path_msgnum, "rebase-merge/msgnum")
6565
/*
6666
* The file to keep track of how many commands are to be processed in total
6767
* (e.g. for the prompt).
6868
*/
69-
static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end");
69+
static GIT_PATH_FUNC(rebase_path_msgtotal, "rebase-merge/end")
7070
/*
7171
* The commit message that is planned to be used for any changes that
7272
* need to be committed following a user interaction.

string-list.c

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -224,18 +224,28 @@ struct string_list_item *string_list_append(struct string_list *list,
224224
list->strdup_strings ? xstrdup(string) : (char *)string);
225225
}
226226

227+
/*
228+
* Encapsulate the compare function pointer because ISO C99 forbids
229+
* casting from void * to a function pointer and vice versa.
230+
*/
231+
struct string_list_sort_ctx
232+
{
233+
compare_strings_fn cmp;
234+
};
235+
227236
static int cmp_items(const void *a, const void *b, void *ctx)
228237
{
229-
compare_strings_fn cmp = ctx;
238+
struct string_list_sort_ctx *sort_ctx = ctx;
230239
const struct string_list_item *one = a;
231240
const struct string_list_item *two = b;
232-
return cmp(one->string, two->string);
241+
return sort_ctx->cmp(one->string, two->string);
233242
}
234243

235244
void string_list_sort(struct string_list *list)
236245
{
237-
QSORT_S(list->items, list->nr, cmp_items,
238-
list->cmp ? list->cmp : strcmp);
246+
struct string_list_sort_ctx sort_ctx = {list->cmp ? list->cmp : strcmp};
247+
248+
QSORT_S(list->items, list->nr, cmp_items, &sort_ctx);
239249
}
240250

241251
struct string_list_item *unsorted_string_list_lookup(struct string_list *list,

utf8.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -566,10 +566,10 @@ static int has_bom_prefix(const char *data, size_t len,
566566
return data && bom && (len >= bom_len) && !memcmp(data, bom, bom_len);
567567
}
568568

569-
static const char utf16_be_bom[] = {0xFE, 0xFF};
570-
static const char utf16_le_bom[] = {0xFF, 0xFE};
571-
static const char utf32_be_bom[] = {0x00, 0x00, 0xFE, 0xFF};
572-
static const char utf32_le_bom[] = {0xFF, 0xFE, 0x00, 0x00};
569+
static const char utf16_be_bom[] = {'\xFE', '\xFF'};
570+
static const char utf16_le_bom[] = {'\xFF', '\xFE'};
571+
static const char utf32_be_bom[] = {'\0', '\0', '\xFE', '\xFF'};
572+
static const char utf32_le_bom[] = {'\xFF', '\xFE', '\0', '\0'};
573573

574574
int has_prohibited_utf_bom(const char *enc, const char *data, size_t len)
575575
{

0 commit comments

Comments
 (0)