Linux wireless drivers development
 help / color / mirror / Atom feed
From: David Laight <David.Laight@ACULAB.COM>
To: 'Dmitry Antipov' <dmantipov@yandex.ru>,
	Larry Finger <Larry.Finger@lwfinger.net>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
	"Kalle Valo" <kvalo@kernel.org>,
	Jonas Gorski <jonas.gorski@gmail.com>,
	"lvc-project@linuxtesting.org" <lvc-project@linuxtesting.org>,
	"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] [v2] wifi: b43: fix cordic arithmetic
Date: Wed, 28 Jun 2023 13:19:23 +0000	[thread overview]
Message-ID: <c3fed52f459b4bea8057b13f89ad6760@AcuMS.aculab.com> (raw)
In-Reply-To: <4482488b-35d8-a2e8-259b-0a39ddffecba@yandex.ru>

From: Dmitry Antipov
> Sent: 28 June 2023 11:45
> 
> On 6/28/23 11:24, David Laight wrote:
> 
> > What are the (u16) casts for?
> 
> Well, this is a kind of a C language purism intended to silence
> warning: conversion from ‘int’ to ‘u16’ {aka ‘short unsigned int’} may change value [-Wconversion]
> observed with W=123.

The problem is that the casts can hide more than just a value being truncated.
In this case the compiler even knows the values don't overflow.

FWIW I've seen generated code for:
	*cp++ = (unsigned char)(value & 0xff);
that masked the value with 0xff once for the & a second time for
the cast and then stored the low byte.
I don't think modern gcc will do that, but a dumb compiler will.

If -Wconversion bleats about these sort of assignments it just
needs permanently disabling (or deleting from the compiler!).

	David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, UK
Registration No: 1397386 (Wales)

      reply	other threads:[~2023-06-28 13:19 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-27 13:00 [PATCH] wifi: b43: fix cordic arithmetic Dmitry Antipov
2023-06-27 14:38 ` Larry Finger
2023-06-27 15:13   ` [PATCH] [v2] " Dmitry Antipov
2023-06-28  8:24     ` David Laight
2023-06-28 10:45       ` Dmitry Antipov
2023-06-28 13:19         ` David Laight [this message]

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=c3fed52f459b4bea8057b13f89ad6760@AcuMS.aculab.com \
    --to=david.laight@aculab.com \
    --cc=Larry.Finger@lwfinger.net \
    --cc=dmantipov@yandex.ru \
    --cc=jonas.gorski@gmail.com \
    --cc=kvalo@kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=lvc-project@linuxtesting.org \
    --cc=stable@vger.kernel.org \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox