More type corrections.

This commit is contained in:
Andrew Wood
2023-09-16 23:14:16 +01:00
parent 20b8c9700a
commit 780b65a648
9 changed files with 35 additions and 29 deletions
+1 -1
View File
@@ -56,7 +56,7 @@ struct opts_s { /* structure describing run-time options */
bool discard_input; /* set to write nothing to stdout */
double interval; /* interval between updates */
double delay_start; /* delay before first display */
unsigned int watch_pid; /* process to watch fds of */
pid_t watch_pid; /* process to watch fds of */
int watch_fd; /* fd to watch */
unsigned int average_rate_window; /* time window in seconds for average rate calculations */
unsigned int width; /* screen width */
+3 -3
View File
@@ -114,7 +114,7 @@ struct pvstate_s {
off_t size; /* total size of data */
double interval; /* interval between updates */
double delay_start; /* delay before first display */
unsigned int watch_pid; /* process to watch fds of */
pid_t watch_pid; /* process to watch fds of */
int watch_fd; /* fd to watch */
unsigned int width; /* screen width */
unsigned int height; /* screen height */
@@ -264,7 +264,7 @@ struct pvstate_s {
struct pvwatchfd_s {
unsigned int watch_pid; /* PID to watch */
pid_t watch_pid; /* PID to watch */
int watch_fd; /* fd to watch, -1 = not displayed */
#ifdef __APPLE__
#else
@@ -309,7 +309,7 @@ int pv_remote_set(pvstate_t);
int pv_watchfd_info(pvstate_t, pvwatchfd_t, int);
int pv_watchfd_changed(pvwatchfd_t);
long long pv_watchfd_position(pvwatchfd_t);
off_t pv_watchfd_position(pvwatchfd_t);
int pv_watchpid_scanfds(pvstate_t, pvstate_t, unsigned int, int *, pvwatchfd_t *, pvstate_t *, int *);
void pv_watchpid_setname(pvstate_t, pvwatchfd_t);
+1 -1
View File
@@ -171,7 +171,7 @@ extern void pv_state_width_set(pvstate_t, unsigned int, bool);
extern void pv_state_height_set(pvstate_t, unsigned int, bool);
extern void pv_state_name_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_format_string_set(pvstate_t, /*@null@*/ const char *);
extern void pv_state_watch_pid_set(pvstate_t, unsigned int);
extern void pv_state_watch_pid_set(pvstate_t, pid_t);
extern void pv_state_watch_fd_set(pvstate_t, int);
extern void pv_state_average_rate_window_set(pvstate_t, unsigned int);
+7 -5
View File
@@ -157,8 +157,8 @@ opts_t opts_parse(unsigned int argc, char **argv)
#endif
;
int c, numopts;
unsigned int check_pid;
int check_fd;
unsigned int check_pid, parse_pid;
int check_fd, parse_fd;
opts_t opts;
char *leafptr;
@@ -465,10 +465,12 @@ opts_t opts_parse(unsigned int argc, char **argv)
}
break;
case 'd':
opts->watch_pid = 0;
opts->watch_fd = -1;
parse_pid = 0;
parse_fd = -1;
/* No syntax check here, already done earlier */
(void) sscanf(optarg, "%u:%d", &(opts->watch_pid), &(opts->watch_fd));
(void) sscanf(optarg, "%u:%d", &parse_pid, &parse_fd);
opts->watch_pid = (pid_t) parse_pid;
opts->watch_fd = parse_fd;
break;
case 'm':
opts->average_rate_window = pv_getnum_count(optarg);
+9 -9
View File
@@ -34,7 +34,8 @@
int pv_main_loop(pvstate_t state)
{
long lineswritten;
off_t written, total_written, transferred_since_last, cansend;
off_t total_written, transferred_since_last, cansend;
ssize_t written;
long double target;
bool eof_in, eof_out, final_update;
struct timespec start_time, next_update, next_ratecheck, cur_time;
@@ -197,6 +198,7 @@ int pv_main_loop(pvstate_t state)
written = pv_transfer(state, fd, &eof_in, &eof_out, cansend, &lineswritten);
}
/* End on write error. */
if (written < 0) {
if (state->cursor)
pv_crs_fini(state);
@@ -363,12 +365,11 @@ int pv_main_loop(pvstate_t state)
int pv_watchfd_loop(pvstate_t state)
{
struct pvwatchfd_s info;
long long position_now, total_written, transferred_since_last;
off_t position_now, total_written, transferred_since_last;
struct timespec next_update, cur_time;
struct timespec init_time, next_remotecheck, transfer_elapsed;
long double elapsed_seconds;
int ended;
int first_check;
bool ended, first_check;
int rc;
memset(&info, 0, sizeof(info));
@@ -407,10 +408,10 @@ int pv_watchfd_loop(pvstate_t state)
pv_elapsedtime_copy(&next_update, &cur_time);
pv_elapsedtime_add_nsec(&next_update, (long long) (1000000000.0 * state->interval));
ended = 0;
ended = false;
total_written = 0;
transferred_since_last = 0;
first_check = 1;
first_check = true;
while (!ended) {
/*
@@ -427,13 +428,13 @@ int pv_watchfd_loop(pvstate_t state)
position_now = pv_watchfd_position(&info);
if (position_now < 0) {
ended = 1;
ended = true;
} else {
transferred_since_last += position_now - total_written;
total_written = position_now;
if (first_check) {
state->initial_offset = position_now;
first_check = 0;
first_check = false;
}
}
@@ -441,7 +442,6 @@ int pv_watchfd_loop(pvstate_t state)
/* Ended - force a display update. */
if (ended) {
ended = 1;
pv_elapsedtime_copy(&next_update, &cur_time);
}
+2 -2
View File
@@ -114,7 +114,7 @@ off_t pv_getnum_size(const char *str)
if (shiftby > 30)
shiftby = 30;
/*@-shiftimplementation@*/
/*@-shiftimplementation@ */
/*
* splint note: ignore the fact that the types we are
* shifting are signed, because we know they are definitely
@@ -122,7 +122,7 @@ off_t pv_getnum_size(const char *str)
*/
integral_part = (off_t) (integral_part << shiftby);
fractional_part = (off_t) (fractional_part << shiftby);
/*@+shiftimplementation@*/
/*@+shiftimplementation@ */
shift -= shiftby;
}
+1 -1
View File
@@ -332,7 +332,7 @@ void pv_state_format_string_set(pvstate_t state, /*@null@ */ const char *val)
state->format_string = pv_strdup(val);
}
void pv_state_watch_pid_set(pvstate_t state, unsigned int val)
void pv_state_watch_pid_set(pvstate_t state, pid_t val)
{
state->watch_pid = val;
}
+3 -1
View File
@@ -777,7 +777,9 @@ static int pv__transfer_write(pvstate_t state, bool *eof_in, bool *eof_out, long
*
* Returns NULL on complete allocation failure.
*/
/*@null@*//*@only@ */ static char *pv__allocate_aligned_buffer(int fd, size_t target_size)
/*@null@*/
/*@only@*/
static char *pv__allocate_aligned_buffer(int fd, size_t target_size)
{
char *newptr;
+8 -6
View File
@@ -211,9 +211,10 @@ int pv_watchfd_changed(pvwatchfd_t info)
* Return the current file position of the given file descriptor, or -1 if
* the fd has closed or has changed in some way.
*/
long long pv_watchfd_position(pvwatchfd_t info)
off_t pv_watchfd_position(pvwatchfd_t info)
{
long long position;
off_t position;
unsigned long long pos_long;
#ifdef __APPLE__
struct vnode_fdinfowithpath vnodeInfo = { };
int32_t proc_fd = (int32_t) info->watch_fd;
@@ -225,7 +226,7 @@ long long pv_watchfd_position(pvwatchfd_t info)
return -1;
}
position = (long long) vnodeInfo.pfi.fi_offset;
position = (off_t) vnodeInfo.pfi.fi_offset;
#else
FILE *fptr;
@@ -235,9 +236,10 @@ long long pv_watchfd_position(pvwatchfd_t info)
fptr = fopen(info->file_fdinfo, "r");
if (NULL == fptr)
return -1;
pos_long = -1;
position = -1;
if (1 != fscanf(fptr, "pos: %llu", &position))
position = -1;
if (1 == fscanf(fptr, "pos: %llu", &pos_long))
position = (off_t) pos_long;
fclose(fptr);
#endif
@@ -317,7 +319,7 @@ int pv_watchpid_scanfds(pvstate_t state, pvstate_t pristine,
while ((d = readdir(dptr)) != NULL) {
#endif
int fd, check_idx, use_idx, rc;
long long position_now;
off_t position_now;
fd = -1;
#ifdef __APPLE__