lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20170112173921.frqgwhqzebs2inoj@earth>
Date:   Thu, 12 Jan 2017 18:39:21 +0100
From:   Sebastian Reichel <sre@...nel.org>
To:     Arnd Bergmann <arnd@...db.de>
Cc:     Chen-Yu Tsai <wens@...e.org>,
        Quentin Schulz <quentin.schulz@...e-electrons.com>,
        linux-pm@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH] power: supply: axp20x_usb_power: fix 64-bit build warning


On Thu, Jan 12, 2017 at 09:32:26AM +0100, Arnd Bergmann wrote:
> On Thursday, January 12, 2017 3:58:24 AM CET Sebastian Reichel wrote:
> > On Wed, Jan 11, 2017 at 03:51:55PM +0100, Arnd Bergmann wrote:
> > > Casting a pointer to 'int' is not always valid:
> > > 
> > > drivers/power/supply/axp20x_usb_power.c: In function 'axp20x_usb_power_probe':
> > > drivers/power/supply/axp20x_usb_power.c:297:21: error: cast from pointer to integer of different size [-Werror=pointer-to-int-cast]
> > > 
> > > This makes the code use uintptr_t explicitly.
> > > 
> > > Fixes: 0dcc70ca8644 ("power: supply: axp20x_usb_power: use of_device_id data field instead of device_is_compatible")
> > > Signed-off-by: Arnd Bergmann <arnd@...db.de>
> > 
> > I queued Michal's patch instead:
> > 
> > https://git.kernel.org/cgit/linux/kernel/git/sre/linux-power-supply.git/commit/?h=for-next&id=15df6d98ec3b40775918fc6ef73d7f1c2d0cf870
> 
> Hmm, that doesn't look right: You can't really rely on an 'enum' type to
> have a specific size, especially not the same size as a pointer, in portable
> code.
> 
> IIRC on many architectures it defaults to 'int' rather than 'long', and
> it might also be 'short' on architectures that default to enums being
> the smallest integer type that fits.

gcc does not generate warnings as far as I can see and the precision
loss itself is not a problem in this case, since we only store the
enum values in the pointer anyways.

I don't mind adding the uintptr_t cast. But in that case it should
probably be added in a few other places, too:

$ git grep of_device_get_match_data | grep "(enum"
drivers/gpu/drm/bridge/adv7511/adv7511_drv.c:		adv7511->type = (enum adv7511_type)of_device_get_match_data(dev);
drivers/i2c/busses/i2c-rcar.c:	priv->devtype = (enum rcar_i2c_type)of_device_get_match_data(dev);
drivers/net/ethernet/renesas/ravb_main.c:	chip_id = (enum ravb_chip_id)of_device_get_match_data(&pdev->dev);
drivers/pci/host/pci-imx6.c:		(enum imx6_pcie_variants)of_device_get_match_data(dev);
drivers/power/supply/axp20x_usb_power.c:	power->axp20x_id = (enum axp20x_variants)of_device_get_match_data(
drivers/reset/hisilicon/hi6220_reset.c:	type = (enum hi6220_reset_ctrl_type)of_device_get_match_data(dev);
drivers/usb/phy/phy-msm-usb.c:	pdata->phy_type = (enum msm_usb_phy_type)of_device_get_match_data(&pdev->dev);

--Sebastian

Download attachment "signature.asc" of type "application/pgp-signature" (834 bytes)

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ