Skip to content

Commit

Permalink
Merge pull request libgit2#6678 from libgit2/ethomson/compat_fixes
Browse files Browse the repository at this point in the history
Several compatibility fixes
  • Loading branch information
ethomson committed Dec 14, 2023
2 parents 82d4414 + 839b249 commit d1bdf2a
Show file tree
Hide file tree
Showing 12 changed files with 36 additions and 21 deletions.
3 changes: 2 additions & 1 deletion deps/ntlmclient/crypt_commoncrypto.c
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,12 @@ bool ntlm_des_encrypt(
ntlm_des_block *plaintext,
ntlm_des_block *key)
{
CCCryptorStatus result;
size_t written;

NTLM_UNUSED(ntlm);

CCCryptorStatus result = CCCrypt(kCCEncrypt,
result = CCCrypt(kCCEncrypt,
kCCAlgorithmDES, kCCOptionECBMode,
key, sizeof(ntlm_des_block), NULL,
plaintext, sizeof(ntlm_des_block),
Expand Down
4 changes: 2 additions & 2 deletions include/git2/sys/stream.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ GIT_BEGIN_DECL
typedef struct git_stream {
int version;

int encrypted : 1,
proxy_support : 1;
unsigned int encrypted : 1,
proxy_support : 1;

/**
* Timeout for read and write operations; can be set to `0` to
Expand Down
2 changes: 1 addition & 1 deletion src/cli/opt.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file was produced by using the `rename.pl` script included with
* adopt. The command-line specified was:
*
* ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
* ./rename.pl cli_opt --filename=opt --include=common.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
*/

#include <stdlib.h>
Expand Down
16 changes: 13 additions & 3 deletions src/cli/opt.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
* This file was produced by using the `rename.pl` script included with
* adopt. The command-line specified was:
*
* ./rename.pl cli_opt --filename=opt --include=cli.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
* ./rename.pl cli_opt --filename=opt --include=common.h --inline=GIT_INLINE --header-guard=CLI_opt_h__ --lowercase-status --without-usage
*/

#ifndef CLI_opt_h__
Expand Down Expand Up @@ -275,8 +275,8 @@ typedef struct cli_opt_parser {
size_t arg_idx;
size_t in_args;
size_t in_short;
int needs_sort : 1,
in_literal : 1;
unsigned int needs_sort : 1,
in_literal : 1;
} cli_opt_parser;

/**
Expand All @@ -300,6 +300,16 @@ cli_opt_status_t cli_opt_parse(
size_t args_len,
unsigned int flags);

/**
* Quickly executes the given callback for each argument.
*
* @param specs A NULL-terminated array of `cli_opt_spec`s that can be parsed
* @param args The arguments that will be parsed
* @param args_len The length of arguments to be parsed
* @param flags The `cli_opt_flag_t flags for parsing
* @param callback The callback to invoke for each specified option
* @param callback_data Data to be provided to the callback
*/
int cli_opt_foreach(
const cli_opt_spec specs[],
char **args,
Expand Down
10 changes: 5 additions & 5 deletions src/libgit2/config_parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,7 @@ static int skip_bom(git_parse_ctx *parser)
*/

/* '\"' -> '"' etc */
static int unescape_line(
char **out, bool *is_multi, const char *ptr, int quote_count)
static int unescape_line(char **out, bool *is_multi, const char *ptr, int *quote_count)
{
char *str, *fixed, *esc;
size_t ptr_len = strlen(ptr), alloc_len;
Expand All @@ -296,7 +295,8 @@ static int unescape_line(

while (*ptr != '\0') {
if (*ptr == '"') {
quote_count++;
if (quote_count)
(*quote_count)++;
} else if (*ptr != '\\') {
*fixed++ = *ptr;
} else {
Expand Down Expand Up @@ -358,7 +358,7 @@ static int parse_multiline_variable(git_config_parser *reader, git_str *value, i
goto next;

if ((error = unescape_line(&proc_line, &multiline,
line, in_quotes)) < 0)
line, &in_quotes)) < 0)
goto out;

/* Add this line to the multiline var */
Expand Down Expand Up @@ -445,7 +445,7 @@ static int parse_variable(git_config_parser *reader, char **var_name, char **var
while (git__isspace(value_start[0]))
value_start++;

if ((error = unescape_line(&value, &multiline, value_start, 0)) < 0)
if ((error = unescape_line(&value, &multiline, value_start, NULL)) < 0)
goto out;

if (multiline) {
Expand Down
4 changes: 2 additions & 2 deletions src/libgit2/refdb_fs.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,8 @@ typedef struct refdb_fs_backend {

git_oid_t oid_type;

int fsync : 1,
sorted : 1;
unsigned int fsync : 1,
sorted : 1;
int peeling_mode;
git_iterator_flag_t iterator_flags;
uint32_t direach_flags;
Expand Down
2 changes: 1 addition & 1 deletion src/libgit2/transports/smart.h
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ int git_smart__update_heads(transport_smart *t, git_vector *symrefs);
/* smart_pkt.c */
typedef struct {
git_oid_t oid_type;
int seen_capabilities: 1;
unsigned int seen_capabilities: 1;
} git_pkt_parse_data;

int git_pkt_parse_line(git_pkt **head, const char **endptr, const char *line, size_t linelen, git_pkt_parse_data *data);
Expand Down
2 changes: 1 addition & 1 deletion src/util/net.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
#define GIT_NET_URL_PARSER_INIT { 0 }

typedef struct {
int hierarchical : 1;
unsigned int hierarchical : 1;

const char *scheme;
const char *user;
Expand Down
8 changes: 4 additions & 4 deletions src/util/process.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
typedef struct git_process git_process;

typedef struct {
int capture_in : 1,
capture_out : 1,
capture_err : 1,
exclude_env : 1;
unsigned int capture_in : 1,
capture_out : 1,
capture_err : 1,
exclude_env : 1;

char *cwd;
} git_process_options;
Expand Down
2 changes: 2 additions & 0 deletions tests/clar/clar.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,10 @@
static void fs_rm(const char *_source);
static void fs_copy(const char *_source, const char *dest);

#ifdef CLAR_FIXTURE_PATH
static const char *
fixture_path(const char *base, const char *fixture_name);
#endif

struct clar_error {
const char *file;
Expand Down
2 changes: 1 addition & 1 deletion tests/clar/clar/fixtures.h
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
#ifdef CLAR_FIXTURE_PATH
static const char *
fixture_path(const char *base, const char *fixture_name)
{
Expand All @@ -20,7 +21,6 @@ fixture_path(const char *base, const char *fixture_name)
return _path;
}

#ifdef CLAR_FIXTURE_PATH
const char *cl_fixture(const char *fixture_name)
{
return fixture_path(CLAR_FIXTURE_PATH, fixture_name);
Expand Down
2 changes: 2 additions & 0 deletions tests/clar/clar/fs.h
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 +295,9 @@ fs_copy(const char *_source, const char *_dest)
void
cl_fs_cleanup(void)
{
#ifdef CLAR_FIXTURE_PATH
fs_rm(fixture_path(_clar_path, "*"));
#endif
}

#else
Expand Down

0 comments on commit d1bdf2a

Please sign in to comment.