All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alexander Lobakin <alexandr.lobakin@intel.com>
To: Jacob Keller <jacob.e.keller@intel.com>
Cc: Alexander Lobakin <alexandr.lobakin@intel.com>,
	davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
	edumazet@google.com, Tony Nguyen <anthony.l.nguyen@intel.com>,
	netdev@vger.kernel.org, richardcochran@gmail.com,
	Gurucharan G <gurucharanx.g@intel.com>
Subject: Re: [PATCH net 2/3] ice: use int for n_per_out loop
Date: Wed,  9 Nov 2022 17:37:12 +0100	[thread overview]
Message-ID: <20221109163712.1154266-1-alexandr.lobakin@intel.com> (raw)
In-Reply-To: <20221108235116.3522941-3-anthony.l.nguyen@intel.com>

From: Tony Nguyen <anthony.l.nguyen@intel.com>
Date: Tue,  8 Nov 2022 15:51:15 -0800

> From: Jacob Keller <jacob.e.keller@intel.com>
> 
> In ice_ptp_enable_all_clkout and ice_ptp_disable_all_clkout we use a uint
> for a for loop iterating over the n_per_out value from the struct
> ptp_clock_info. The struct member is a signed int, and the use of uint
> generates a -Wsign-compare warning:
> 
>   drivers/net/ethernet/intel/ice/ice_ptp.c: In function ‘ice_ptp_enable_all_clkout’:
>   drivers/net/ethernet/intel/ice/ice_ptp.c:1710:23: error: comparison of integer expressions of different signedness: ‘uint’ {aka ‘unsigned int’} and ‘int’ [-Werror=sign-compare]
>    1710 |         for (i = 0; i < pf->ptp.info.n_per_out; i++)
>         |                       ^
>   cc1: all warnings being treated as errors
> 
> While we don't generally compile with -Wsign-compare, its still a good idea

-Wsign-compare is disabled even on W=2.

> not to mix types. Fix the two functions to use a plain signed integer.

It's still a good idea to not use ints when values below zero are
not used. Here both @i's are used as iterators from zero and above.
The change is just pointless. I would even understand if you casted
::n_per_out to `u32` in the loop condition and -Wsign-compare was
enabled on W=1 or 2, but not this.

> 
> Fixes: 9ee313433c48 ("ice: restart periodic outputs around time changes")

...even more pointless to send it to net, not net-next, it doesn't
fix anything. If you manually enable the warning via KCFLAGS, you'll
see thousands of them.

> Signed-off-by: Jacob Keller <jacob.e.keller@intel.com>
> Tested-by: Gurucharan G <gurucharanx.g@intel.com> (A Contingent worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
>  drivers/net/ethernet/intel/ice/ice_ptp.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/intel/ice/ice_ptp.c b/drivers/net/ethernet/intel/ice/ice_ptp.c
> index 011b727ab190..be147fb641ae 100644
> --- a/drivers/net/ethernet/intel/ice/ice_ptp.c
> +++ b/drivers/net/ethernet/intel/ice/ice_ptp.c
> @@ -1688,7 +1688,7 @@ static int ice_ptp_cfg_clkout(struct ice_pf *pf, unsigned int chan,
>   */
>  static void ice_ptp_disable_all_clkout(struct ice_pf *pf)
>  {
> -	uint i;
> +	int i;
>  
>  	for (i = 0; i < pf->ptp.info.n_per_out; i++)
>  		if (pf->ptp.perout_channels[i].ena)
> @@ -1705,7 +1705,7 @@ static void ice_ptp_disable_all_clkout(struct ice_pf *pf)
>   */
>  static void ice_ptp_enable_all_clkout(struct ice_pf *pf)
>  {
> -	uint i;
> +	int i;
>  
>  	for (i = 0; i < pf->ptp.info.n_per_out; i++)
>  		if (pf->ptp.perout_channels[i].ena)
> -- 
> 2.35.1

Thanks,
Olek

  reply	other threads:[~2022-11-09 16:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-08 23:51 [PATCH net 0/3][pull request] Intel Wired LAN Driver Updates 2022-11-08 (ice, iavf) Tony Nguyen
2022-11-08 23:51 ` [PATCH net 1/3] ice: Fix spurious interrupt during removal of trusted VF Tony Nguyen
2022-11-08 23:51 ` [PATCH net 2/3] ice: use int for n_per_out loop Tony Nguyen
2022-11-09 16:37   ` Alexander Lobakin [this message]
2022-11-09 20:19     ` Jacob Keller
2022-11-08 23:51 ` [PATCH net 3/3] iavf: Fix VF driver counting VLAN 0 filters Tony Nguyen

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221109163712.1154266-1-alexandr.lobakin@intel.com \
    --to=alexandr.lobakin@intel.com \
    --cc=anthony.l.nguyen@intel.com \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=gurucharanx.g@intel.com \
    --cc=jacob.e.keller@intel.com \
    --cc=kuba@kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=richardcochran@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.