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] [thread-next>] [day] [month] [year] [list]
Date:   Wed, 28 Jun 2023 13:55:53 -0700
From:   Rahul Rameshbabu <rrameshbabu@...dia.com>
To:     Andrew Lunn <andrew@...n.ch>
Cc:     Jakub Kicinski <kuba@...nel.org>, netdev@...r.kernel.org,
        Richard Cochran <richardcochran@...il.com>,
        Paolo Abeni <pabeni@...hat.com>,
        Saeed Mahameed <saeed@...nel.org>,
        Gal Pressman <gal@...dia.com>,
        "David S. Miller" <davem@...emloft.net>,
        lkft-triage@...ts.linaro.org, LTP List <ltp@...ts.linux.it>,
        Nathan Chancellor <nathan@...nel.org>,
        Naresh Kamboju <naresh.kamboju@...aro.org>,
        Linux Kernel Functional Testing <lkft@...aro.org>
Subject: Re: [PATCH net v1] ptp: Make max_phase_adjustment sysfs device
 attribute invisible when not supported

On Wed, 28 Jun, 2023 22:46:32 +0200 Andrew Lunn <andrew@...n.ch> wrote:
> On Wed, Jun 28, 2023 at 01:38:50PM -0700, Jakub Kicinski wrote:
>> On Wed, 28 Jun 2023 03:16:43 +0200 Andrew Lunn wrote:
>> > > +	} else if (attr == &dev_attr_max_phase_adjustment.attr) {
>> > > +		if (!info->adjphase || !info->getmaxphase)
>> > > +			mode = 0;  
>> > 
>> > Maybe it is time to turn this into a switch statement?
>> 
>> I don't think we can switch on pointers in C.
>
> https://elixir.bootlin.com/linux/latest/source/drivers/net/phy/sfp.c#L749
>
> Works for temperature sensors, voltage sensors, current sensors, and
> power sensors. Maybe hwmon is different to what is going on here, but
> both a sysfs files.

Sorry, the only switch cases I see in the link you shared are for an
integral type enum and a u32. I do not see a pointer type being used in
a switch in sfp_hwmon_is_visible?

I believe Jakub is right about pointer types + switches in C. pointer
types are not considered integral types. Here is a compiler explorer
example to demonstrate. This slipped my mind during our discussion.

https://godbolt.org/z/nKr3x7cT8

  <source>: In function 'main':
  <source>:6:13: error: switch quantity not an integer
      6 |     switch (data) {
        |             ^~~~
  Compiler returned: 1

-- Rahul Rameshbabu

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ