Skip to content

Commit cfa9706

Browse files
committed
Merge branch 'js/gcc-8-and-9' into jch
Code clean-up for new compilers. * js/gcc-8-and-9: config: avoid calling `labs()` on too-large data type winansi: simplify loading the GetCurrentConsoleFontEx() function kwset: allow building with GCC 8 poll (mingw): allow compiling with GCC 8 and DEVELOPER=1
2 parents 76785e6 + 9dae4fe commit cfa9706

File tree

4 files changed

+15
-13
lines changed

4 files changed

+15
-13
lines changed

compat/poll/poll.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ win32_compute_revents (HANDLE h, int *p_sought)
149149
case FILE_TYPE_PIPE:
150150
if (!once_only)
151151
{
152-
NtQueryInformationFile = (PNtQueryInformationFile)
152+
NtQueryInformationFile = (PNtQueryInformationFile)(void (*)(void))
153153
GetProcAddress (GetModuleHandle ("ntdll.dll"),
154154
"NtQueryInformationFile");
155155
once_only = TRUE;

compat/winansi.c

+5-9
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
#include <wingdi.h>
88
#include <winreg.h>
99
#include "win32.h"
10+
#include "win32/lazyload.h"
1011

1112
static int fd_is_interactive[3] = { 0, 0, 0 };
1213
#define FD_CONSOLE 0x1
@@ -41,26 +42,21 @@ typedef struct _CONSOLE_FONT_INFOEX {
4142
#endif
4243
#endif
4344

44-
typedef BOOL (WINAPI *PGETCURRENTCONSOLEFONTEX)(HANDLE, BOOL,
45-
PCONSOLE_FONT_INFOEX);
46-
4745
static void warn_if_raster_font(void)
4846
{
4947
DWORD fontFamily = 0;
50-
PGETCURRENTCONSOLEFONTEX pGetCurrentConsoleFontEx;
48+
DECLARE_PROC_ADDR(kernel32.dll, BOOL, GetCurrentConsoleFontEx,
49+
HANDLE, BOOL, PCONSOLE_FONT_INFOEX);
5150

5251
/* don't bother if output was ascii only */
5352
if (!non_ascii_used)
5453
return;
5554

5655
/* GetCurrentConsoleFontEx is available since Vista */
57-
pGetCurrentConsoleFontEx = (PGETCURRENTCONSOLEFONTEX) GetProcAddress(
58-
GetModuleHandle("kernel32.dll"),
59-
"GetCurrentConsoleFontEx");
60-
if (pGetCurrentConsoleFontEx) {
56+
if (INIT_PROC_ADDR(GetCurrentConsoleFontEx)) {
6157
CONSOLE_FONT_INFOEX cfi;
6258
cfi.cbSize = sizeof(cfi);
63-
if (pGetCurrentConsoleFontEx(console, 0, &cfi))
59+
if (GetCurrentConsoleFontEx(console, 0, &cfi))
6460
fontFamily = cfi.FontFamily;
6561
} else {
6662
/* pre-Vista: check default console font in registry */

config.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -896,9 +896,9 @@ static int git_parse_signed(const char *value, intmax_t *ret, intmax_t max)
896896
errno = EINVAL;
897897
return 0;
898898
}
899-
uval = labs(val);
899+
uval = val < 0 ? -val : val;
900900
uval *= factor;
901-
if (uval > max || labs(val) > uval) {
901+
if (uval > max || (val < 0 ? -val : val) > uval) {
902902
errno = ERANGE;
903903
return 0;
904904
}

kwset.c

+7-1
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,13 @@
3838
#include "compat/obstack.h"
3939

4040
#define NCHAR (UCHAR_MAX + 1)
41-
#define obstack_chunk_alloc xmalloc
41+
/* adapter for `xmalloc()`, which takes `size_t`, not `long` */
42+
static void *obstack_chunk_alloc(long size)
43+
{
44+
if (size < 0)
45+
BUG("Cannot allocate a negative amount: %ld", size);
46+
return xmalloc(size);
47+
}
4248
#define obstack_chunk_free free
4349

4450
#define U(c) ((unsigned char) (c))

0 commit comments

Comments
 (0)