RE: [PATCH] rsockets: fix variable initialization

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> diff --git a/librdmacm/rsocket.c b/librdmacm/rsocket.c
> index 58de2856..aa912c1a 100644
> --- a/librdmacm/rsocket.c
> +++ b/librdmacm/rsocket.c
> @@ -2133,7 +2133,7 @@ static int rs_process_cq(struct rsocket *rs, int nonblock, int
> (*test)(struct rs
> 
>  static int rs_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket
> *rs))
>  {
> -	uint64_t start_time;
> +	uint64_t start_time = 0;
>  	uint32_t poll_time = 0;
>  	int ret;
> 
> @@ -2292,7 +2292,7 @@ static int ds_process_cqs(struct rsocket *rs, int nonblock, int
> (*test)(struct r
> 
>  static int ds_get_comp(struct rsocket *rs, int nonblock, int (*test)(struct rsocket
> *rs))
>  {
> -	uint64_t start_time;
> +	uint64_t start_time = 0;
>  	uint32_t poll_time = 0;
>  	int ret;
> 
> @@ -3306,7 +3306,7 @@ static int rs_poll_events(struct pollfd *rfds, struct pollfd
> *fds, nfds_t nfds)
>  int rpoll(struct pollfd *fds, nfds_t nfds, int timeout)
>  {
>  	struct pollfd *rfds;
> -	uint64_t start_time;
> +	uint64_t start_time = 0;
>  	uint32_t poll_time = 0;
>  	int pollsleep, ret;

Because poll_time is initialized to 0, these end up being false warnings.  However, it may be cleaner to init start_time = 0, leave poll_time unitialized, and change the following check further down in the code:

	if (!poll_time) --> if (!start_time)
		start_time = rs_time_us();

That should eliminate the warning and leave the code with the same number of assignments.

- Sean




[Index of Archives]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Photo]     [Yosemite News]     [Yosemite Photos]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux