libflow: avoid types size_t and ssize_t in libflow.h

Those types are not included in libflow.h and
including them is overwhelming.
This commit is contained in:
Michel Machado 2020-06-23 07:35:05 -04:00
parent 099eb7fd42
commit 5ac9551d87
4 changed files with 7 additions and 9 deletions

View File

@ -192,7 +192,7 @@ static ssize_t read_all(int fd, char *buf, size_t count)
} }
static ssize_t check_chunk(int fd, uint64_t *p_expected_offset, static ssize_t check_chunk(int fd, uint64_t *p_expected_offset,
size_t chunk_size, struct file_stats *stats) uint64_t chunk_size, struct file_stats *stats)
{ {
char buf[MAX_BUFFER_SIZE]; char buf[MAX_BUFFER_SIZE];
ssize_t tot_bytes_read = 0; ssize_t tot_bytes_read = 0;

View File

@ -203,7 +203,7 @@ static int create_and_fill_file(const char *path, long number, size_t size,
remaining = size; remaining = size;
start_measurement(fw); start_measurement(fw);
while (remaining > 0) { while (remaining > 0) {
size_t write_size = get_rem_chunk_size(fw); uint64_t write_size = get_rem_chunk_size(fw);
if (write_size > remaining) if (write_size > remaining)
write_size = remaining; write_size = remaining;
saved_errno = write_chunk(fd, write_size, &offset); saved_errno = write_chunk(fd, write_size, &offset);

View File

@ -244,7 +244,7 @@ static inline uint64_t diff_timeval_us(const struct timeval *t1,
t2->tv_usec - t1->tv_usec; t2->tv_usec - t1->tv_usec;
} }
int measure(int fd, struct flow *fw, ssize_t processed) int measure(int fd, struct flow *fw, long processed)
{ {
ldiv_t result = ldiv(processed, fw->block_size); ldiv_t result = ldiv(processed, fw->block_size);
struct timeval t2; struct timeval t2;

View File

@ -63,7 +63,7 @@ void init_flow(struct flow *fw, uint64_t total_size,
flow_func_flush_chunk_t func_flush_chunk); flow_func_flush_chunk_t func_flush_chunk);
void start_measurement(struct flow *fw); void start_measurement(struct flow *fw);
int measure(int fd, struct flow *fw, ssize_t processed); int measure(int fd, struct flow *fw, long processed);
int end_measurement(int fd, struct flow *fw); int end_measurement(int fd, struct flow *fw);
static inline int has_enough_measurements(const struct flow *fw) static inline int has_enough_measurements(const struct flow *fw)
@ -84,12 +84,10 @@ static inline double get_avg_speed(struct flow *fw)
return get_avg_speed_given_time(fw, fw->measured_time_ms); return get_avg_speed_given_time(fw, fw->measured_time_ms);
} }
static inline size_t get_rem_chunk_size(struct flow *fw) static inline uint64_t get_rem_chunk_size(struct flow *fw)
{ {
ssize_t ret = (fw->blocks_per_delay - fw->processed_blocks) * assert(fw->blocks_per_delay > fw->processed_blocks);
fw->block_size; return (fw->blocks_per_delay - fw->processed_blocks) * fw->block_size;
assert(ret > 0);
return ret;
} }
#define MAX_BUFFER_SIZE (1<<21) /* 2MB */ #define MAX_BUFFER_SIZE (1<<21) /* 2MB */