mirror of
https://github.com/git-for-windows/git.git
synced 2026-06-01 07:08:34 -05:00
object-file.c: use size_t for header lengths
Continue walking the code path for the >4GB `hash-object --literally` test. The `hash_object_file_literally()` function internally uses both `hash_object_file()` and `write_object_file_prepare()`. Both function signatures use `unsigned long` rather than `size_t` for the mem buffer sizes. Use `size_t` instead, for LLP64 compatibility. While at it, convert those function's object's header buffer length to `size_t` for consistency. The value is already upcast to `uintmax_t` for print format compatibility. Note: The hash-object test still does not pass. A subsequent commit continues to walk the call tree's lower level hash functions to identify further fixes. Signed-off-by: Philip Oakley <philipoakley@iee.email> Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
committed by
Johannes Schindelin
parent
23fe600251
commit
c22d98bc72
@@ -1937,7 +1937,7 @@ void *read_object_with_reference(struct repository *r,
|
|||||||
static void hash_object_body(const struct git_hash_algo *algo, git_hash_ctx *c,
|
static void hash_object_body(const struct git_hash_algo *algo, git_hash_ctx *c,
|
||||||
const void *buf, unsigned long len,
|
const void *buf, unsigned long len,
|
||||||
struct object_id *oid,
|
struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, size_t *hdrlen)
|
||||||
{
|
{
|
||||||
algo->init_fn(c);
|
algo->init_fn(c);
|
||||||
algo->update_fn(c, hdr, *hdrlen);
|
algo->update_fn(c, hdr, *hdrlen);
|
||||||
@@ -1946,9 +1946,9 @@ static void hash_object_body(const struct git_hash_algo *algo, git_hash_ctx *c,
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void write_object_file_prepare(const struct git_hash_algo *algo,
|
static void write_object_file_prepare(const struct git_hash_algo *algo,
|
||||||
const void *buf, unsigned long len,
|
const void *buf, size_t len,
|
||||||
enum object_type type, struct object_id *oid,
|
enum object_type type, struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, size_t *hdrlen)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
git_hash_ctx c;
|
||||||
|
|
||||||
@@ -1962,7 +1962,7 @@ static void write_object_file_prepare(const struct git_hash_algo *algo,
|
|||||||
static void write_object_file_prepare_literally(const struct git_hash_algo *algo,
|
static void write_object_file_prepare_literally(const struct git_hash_algo *algo,
|
||||||
const void *buf, size_t len,
|
const void *buf, size_t len,
|
||||||
const char *type, struct object_id *oid,
|
const char *type, struct object_id *oid,
|
||||||
char *hdr, int *hdrlen)
|
char *hdr, size_t *hdrlen)
|
||||||
{
|
{
|
||||||
git_hash_ctx c;
|
git_hash_ctx c;
|
||||||
|
|
||||||
@@ -2082,17 +2082,17 @@ out:
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void hash_object_file_literally(const struct git_hash_algo *algo,
|
static void hash_object_file_literally(const struct git_hash_algo *algo,
|
||||||
const void *buf, unsigned long len,
|
const void *buf, size_t len,
|
||||||
const char *type, struct object_id *oid)
|
const char *type, struct object_id *oid)
|
||||||
{
|
{
|
||||||
char hdr[MAX_HEADER_LEN];
|
char hdr[MAX_HEADER_LEN];
|
||||||
int hdrlen = sizeof(hdr);
|
size_t hdrlen = sizeof(hdr);
|
||||||
|
|
||||||
write_object_file_prepare_literally(algo, buf, len, type, oid, hdr, &hdrlen);
|
write_object_file_prepare_literally(algo, buf, len, type, oid, hdr, &hdrlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
|
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
|
||||||
unsigned long len, enum object_type type,
|
size_t len, enum object_type type,
|
||||||
struct object_id *oid)
|
struct object_id *oid)
|
||||||
{
|
{
|
||||||
hash_object_file_literally(algo, buf, len, type_name(type), oid);
|
hash_object_file_literally(algo, buf, len, type_name(type), oid);
|
||||||
@@ -2458,7 +2458,7 @@ cleanup:
|
|||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
int write_object_file_flags(const void *buf, unsigned long len,
|
int write_object_file_flags(const void *buf, size_t len,
|
||||||
enum object_type type, struct object_id *oid,
|
enum object_type type, struct object_id *oid,
|
||||||
struct object_id *compat_oid_in, unsigned flags)
|
struct object_id *compat_oid_in, unsigned flags)
|
||||||
{
|
{
|
||||||
@@ -2467,7 +2467,7 @@ int write_object_file_flags(const void *buf, unsigned long len,
|
|||||||
const struct git_hash_algo *compat = repo->compat_hash_algo;
|
const struct git_hash_algo *compat = repo->compat_hash_algo;
|
||||||
struct object_id compat_oid;
|
struct object_id compat_oid;
|
||||||
char hdr[MAX_HEADER_LEN];
|
char hdr[MAX_HEADER_LEN];
|
||||||
int hdrlen = sizeof(hdr);
|
size_t hdrlen = sizeof(hdr);
|
||||||
|
|
||||||
/* Generate compat_oid */
|
/* Generate compat_oid */
|
||||||
if (compat) {
|
if (compat) {
|
||||||
@@ -2507,8 +2507,8 @@ int write_object_file_literally(const void *buf, size_t len,
|
|||||||
const struct git_hash_algo *algo = repo->hash_algo;
|
const struct git_hash_algo *algo = repo->hash_algo;
|
||||||
const struct git_hash_algo *compat = repo->compat_hash_algo;
|
const struct git_hash_algo *compat = repo->compat_hash_algo;
|
||||||
struct object_id compat_oid;
|
struct object_id compat_oid;
|
||||||
int hdrlen, status = 0;
|
size_t hdrlen;
|
||||||
int compat_type = -1;
|
int status = 0, compat_type = -1;
|
||||||
|
|
||||||
if (compat) {
|
if (compat) {
|
||||||
compat_type = type_from_string_gently(type, -1, 1);
|
compat_type = type_from_string_gently(type, -1, 1);
|
||||||
|
|||||||
@@ -270,10 +270,10 @@ void *repo_read_object_file(struct repository *r,
|
|||||||
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
|
int oid_object_info(struct repository *r, const struct object_id *, unsigned long *);
|
||||||
|
|
||||||
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
|
void hash_object_file(const struct git_hash_algo *algo, const void *buf,
|
||||||
unsigned long len, enum object_type type,
|
size_t len, enum object_type type,
|
||||||
struct object_id *oid);
|
struct object_id *oid);
|
||||||
|
|
||||||
int write_object_file_flags(const void *buf, unsigned long len,
|
int write_object_file_flags(const void *buf, size_t len,
|
||||||
enum object_type type, struct object_id *oid,
|
enum object_type type, struct object_id *oid,
|
||||||
struct object_id *comapt_oid_in, unsigned flags);
|
struct object_id *comapt_oid_in, unsigned flags);
|
||||||
static inline int write_object_file(const void *buf, unsigned long len,
|
static inline int write_object_file(const void *buf, unsigned long len,
|
||||||
|
|||||||
Reference in New Issue
Block a user