Loading libsparse/include/sparse/sparse.h +8 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _LIBSPARSE_SPARSE_H_ #include <stdbool.h> #include <stddef.h> #include <stdint.h> #ifdef __cplusplus Loading @@ -26,6 +27,11 @@ extern "C" { struct sparse_file; // The callbacks in sparse_file_callback() and sparse_file_foreach_chunk() take // size_t as the length type (was `int` in past). This allows clients to keep // their codes compatibile with both versions as needed. #define SPARSE_CALLBACK_USES_SIZE_T /** * sparse_file_new - create a new sparse file cookie * Loading Loading @@ -201,7 +207,7 @@ unsigned int sparse_file_block_size(struct sparse_file *s); * Returns 0 on success, negative errno on error. */ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len), void *priv); int (*write)(void *priv, const void *data, size_t len), void *priv); /** * sparse_file_foreach_chunk - call a callback for data blocks in sparse file Loading @@ -218,7 +224,7 @@ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, * Returns 0 on success, negative errno on error. */ int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len, unsigned int block, int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks), void *priv); /** Loading libsparse/output_file.c +3 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ struct output_file_normal { struct output_file_callback { struct output_file out; void *priv; int (*write)(void *priv, const void *buf, int len); int (*write)(void *priv, const void *buf, size_t len); }; #define to_output_file_callback(_o) \ Loading Loading @@ -634,7 +634,8 @@ static struct output_file *output_file_new_normal(void) return &outn->out; } struct output_file *output_file_open_callback(int (*write)(void *, const void *, int), struct output_file *output_file_open_callback( int (*write)(void *, const void *, size_t), void *priv, unsigned int block_size, int64_t len, int gz __unused, int sparse, int chunks, int crc) { Loading libsparse/output_file.h +2 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,8 @@ struct output_file; struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t len, int gz, int sparse, int chunks, int crc); struct output_file *output_file_open_callback(int (*write)(void *, const void *, int), struct output_file *output_file_open_callback( int (*write)(void *, const void *, size_t), void *priv, unsigned int block_size, int64_t len, int gz, int sparse, int chunks, int crc); int write_data_chunk(struct output_file *out, unsigned int len, void *data); Loading libsparse/sparse.c +6 −6 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse, } int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len), void *priv) int (*write)(void *priv, const void *data, size_t len), void *priv) { int ret; int chunks; Loading @@ -203,11 +203,11 @@ struct chunk_data { void *priv; unsigned int block; unsigned int nr_blocks; int (*write)(void *priv, const void *data, int len, unsigned int block, unsigned int nr_blocks); int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks); }; static int foreach_chunk_write(void *priv, const void *data, int len) static int foreach_chunk_write(void *priv, const void *data, size_t len) { struct chunk_data *chk = priv; Loading @@ -215,7 +215,7 @@ static int foreach_chunk_write(void *priv, const void *data, int len) } int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len, unsigned int block, int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks), void *priv) { Loading Loading @@ -250,7 +250,7 @@ int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, return ret; } static int out_counter_write(void *priv, const void *data __unused, int len) static int out_counter_write(void *priv, const void *data __unused, size_t len) { int64_t *count = priv; *count += len; Loading Loading
libsparse/include/sparse/sparse.h +8 −2 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ #define _LIBSPARSE_SPARSE_H_ #include <stdbool.h> #include <stddef.h> #include <stdint.h> #ifdef __cplusplus Loading @@ -26,6 +27,11 @@ extern "C" { struct sparse_file; // The callbacks in sparse_file_callback() and sparse_file_foreach_chunk() take // size_t as the length type (was `int` in past). This allows clients to keep // their codes compatibile with both versions as needed. #define SPARSE_CALLBACK_USES_SIZE_T /** * sparse_file_new - create a new sparse file cookie * Loading Loading @@ -201,7 +207,7 @@ unsigned int sparse_file_block_size(struct sparse_file *s); * Returns 0 on success, negative errno on error. */ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len), void *priv); int (*write)(void *priv, const void *data, size_t len), void *priv); /** * sparse_file_foreach_chunk - call a callback for data blocks in sparse file Loading @@ -218,7 +224,7 @@ int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, * Returns 0 on success, negative errno on error. */ int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len, unsigned int block, int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks), void *priv); /** Loading
libsparse/output_file.c +3 −2 Original line number Diff line number Diff line Loading @@ -109,7 +109,7 @@ struct output_file_normal { struct output_file_callback { struct output_file out; void *priv; int (*write)(void *priv, const void *buf, int len); int (*write)(void *priv, const void *buf, size_t len); }; #define to_output_file_callback(_o) \ Loading Loading @@ -634,7 +634,8 @@ static struct output_file *output_file_new_normal(void) return &outn->out; } struct output_file *output_file_open_callback(int (*write)(void *, const void *, int), struct output_file *output_file_open_callback( int (*write)(void *, const void *, size_t), void *priv, unsigned int block_size, int64_t len, int gz __unused, int sparse, int chunks, int crc) { Loading
libsparse/output_file.h +2 −1 Original line number Diff line number Diff line Loading @@ -27,7 +27,8 @@ struct output_file; struct output_file *output_file_open_fd(int fd, unsigned int block_size, int64_t len, int gz, int sparse, int chunks, int crc); struct output_file *output_file_open_callback(int (*write)(void *, const void *, int), struct output_file *output_file_open_callback( int (*write)(void *, const void *, size_t), void *priv, unsigned int block_size, int64_t len, int gz, int sparse, int chunks, int crc); int write_data_chunk(struct output_file *out, unsigned int len, void *data); Loading
libsparse/sparse.c +6 −6 Original line number Diff line number Diff line Loading @@ -179,7 +179,7 @@ int sparse_file_write(struct sparse_file *s, int fd, bool gz, bool sparse, } int sparse_file_callback(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len), void *priv) int (*write)(void *priv, const void *data, size_t len), void *priv) { int ret; int chunks; Loading @@ -203,11 +203,11 @@ struct chunk_data { void *priv; unsigned int block; unsigned int nr_blocks; int (*write)(void *priv, const void *data, int len, unsigned int block, unsigned int nr_blocks); int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks); }; static int foreach_chunk_write(void *priv, const void *data, int len) static int foreach_chunk_write(void *priv, const void *data, size_t len) { struct chunk_data *chk = priv; Loading @@ -215,7 +215,7 @@ static int foreach_chunk_write(void *priv, const void *data, int len) } int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, int (*write)(void *priv, const void *data, int len, unsigned int block, int (*write)(void *priv, const void *data, size_t len, unsigned int block, unsigned int nr_blocks), void *priv) { Loading Loading @@ -250,7 +250,7 @@ int sparse_file_foreach_chunk(struct sparse_file *s, bool sparse, bool crc, return ret; } static int out_counter_write(void *priv, const void *data __unused, int len) static int out_counter_write(void *priv, const void *data __unused, size_t len) { int64_t *count = priv; *count += len; Loading