Commit 887eaf4d by Carlos Martín Nieto Committed by Vicent Marti

Fix dev branch under MSVC

In libgit2: Move an enum out of an int bitfield in the HTTP transport.

In the parser: Use int bitfields and change some variable sizes to
better fit thir use. Variables that count the size of the data chunk
can only ever be as large as off_t. Warning 4127 can be ignored, as
nobody takes it seriously anyway.

From Emeric: change some variable declarations to keep MSVC happy.

Signed-off-by: Carlos Martín Nieto <carlos@cmartin.tk>
parent dc5c8781
......@@ -53,7 +53,7 @@ OPTION (BUILD_CLAY "Build Tests using the Clay suite" ON)
# Platform specific compilation flags
IF (MSVC)
SET(CMAKE_C_FLAGS "/W4 /WX /nologo /Zi")
SET(CMAKE_C_FLAGS "/W4 /WX /nologo /Zi /wd4127")
IF (STDCALL)
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /Gz")
ENDIF ()
......
......@@ -364,11 +364,13 @@ size_t http_parser_execute (http_parser *parser,
char c, ch;
int8_t unhex_val;
const char *p = data, *pe;
int64_t to_read;
off_t to_read;
enum state state;
enum header_states header_state;
uint64_t index = parser->index;
uint64_t nread = parser->nread;
const char *header_field_mark, *header_value_mark, *url_mark;
const char *matcher;
/* We're in an error state. Don't bother doing anything. */
if (HTTP_PARSER_ERRNO(parser) != HPE_OK) {
......@@ -399,9 +401,9 @@ size_t http_parser_execute (http_parser *parser,
/* technically we could combine all of these (except for url_mark) into one
variable, saving stack space, but it seems more clear to have them
separated. */
const char *header_field_mark = 0;
const char *header_value_mark = 0;
const char *url_mark = 0;
header_field_mark = 0;
header_value_mark = 0;
url_mark = 0;
if (state == s_header_field)
header_field_mark = data;
......@@ -695,7 +697,7 @@ size_t http_parser_execute (http_parser *parser,
goto error;
}
const char *matcher = method_strings[parser->method];
matcher = method_strings[parser->method];
if (ch == ' ' && matcher[index] == '\0') {
state = s_req_spaces_before_url;
} else if (ch == matcher[index]) {
......@@ -1576,7 +1578,7 @@ size_t http_parser_execute (http_parser *parser,
}
case s_body_identity:
to_read = MIN(pe - p, (int64_t)parser->content_length);
to_read = (off_t) MIN(pe - p, parser->content_length);
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);
p += to_read - 1;
......@@ -1670,7 +1672,7 @@ size_t http_parser_execute (http_parser *parser,
{
assert(parser->flags & F_CHUNKED);
to_read = MIN(pe - p, (int64_t)(parser->content_length));
to_read = (off_t) MIN(pe - p, parser->content_length);
if (to_read > 0) {
if (settings->on_body) settings->on_body(parser, p, to_read);
......@@ -1710,7 +1712,7 @@ size_t http_parser_execute (http_parser *parser,
parser->state = state;
parser->header_state = header_state;
parser->index = index;
parser->index = (unsigned char) index;
parser->nread = nread;
return len;
......
......@@ -33,11 +33,11 @@
#include "buffer.h"
#include "pkt.h"
typedef enum {
enum last_cb {
NONE,
FIELD,
VALUE
} last_cb_type;
};
typedef struct {
git_transport parent;
......@@ -48,8 +48,8 @@ typedef struct {
int error;
int transfer_finished :1,
ct_found :1,
ct_finished :1,
last_cb :3;
ct_finished :1;
enum last_cb last_cb;
char *content_type;
char *service;
} transport_http;
......@@ -75,10 +75,13 @@ static int gen_request(git_buf *buf, const char *url, const char *host, const ch
static int do_connect(transport_http *t, const char *service)
{
int s = -1, error;;
const char *url = t->parent.url, *prefix = "http://";
char *host = NULL, *port = NULL;
git_buf request = GIT_BUF_INIT;
int s = -1, error;
const char *url, *prefix;
char *host = NULL, *port = NULL;
url = t->parent.url;
prefix = "http://";
if (!git__prefixcmp(url, prefix))
url += strlen(prefix);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment