All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Barnabás Pőcze" <pobrn@protonmail.com>
To: Guenter Roeck <linux@roeck-us.net>
Cc: jaap aarts <jaap.aarts1@gmail.com>,
	Jean Delvare <jdelvare@suse.com>,
	"linux-hwmon@vger.kernel.org" <linux-hwmon@vger.kernel.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Subject: Re: [PATCH V4] hwmon: add fan/pwm driver for corsair h100i platinum
Date: Sun, 16 Aug 2020 01:35:10 +0000	[thread overview]
Message-ID: <jXVNMOMJ1nqEEhjQbWGsgeGm0TWaNDSHsp-YOtCWb-Sx3NqjIEGQKjUzA8FuUgvwXijS-fUWIfokZ--M3aCZUusFduP_EHXyaiMIfdPguQY=@protonmail.com> (raw)
In-Reply-To: <38cb8109-0868-c00c-e701-050cc0b20ac9@roeck-us.net>

2020. augusztus 16., vasárnap 2:51 keltezéssel, Guenter Roeck írta:

> On 8/15/20 5:27 PM, Barnabás Pőcze wrote:
> >> [...]
> >>>> +			if (val < (2 ^ 16) - 2)
> >>>
> >>> Did you intend to write 2 to the power of 16? Because 2^16 is not that.
> >>> 2 to the power 16 may be written as '(1 << 16)' or 'BIT(16)'
> >>> (you may need to include linux/bits.h for the latter)
> >>>
> >>> But something like this is my suggestion:
> >>>
> >>> if (val < 0 || 0xFFFF < val)
> >>> 	return -EINVAL;
> >>>
> >>
> >> I would suggest to use clamp_val; we don't expect users to know device
> >> specific limits. Also, FTR, I won't accept any Yoda programming.
> >>
> >> Guenter
> >> [...]
> >
> >
> > If you don't mind me asking, why is that? I, too, don't like Yoda conditions,
> > but I've always thought that in this specific case - when checking if a value
> > lies within/outside a certain range - it makes the code more easily readable
> > if it is written like this: (lo < val && val < hi).
> >
>
> You are suggesting (val < lo || hi < val) here, which is a bit different.
>
> Anyway, good for you. If you are signing up as code reviewer for a Linux kernel
> subsystem, please feel free to accept and promote such code. For me, it is just
> confusing.
>
> Guenter
>

Thank you for the answer.


Barnabás Pőcze

  reply	other threads:[~2020-08-16  1:35 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-15 21:16 [PATCH V4] hwmon: add fan/pwm driver for corsair h100i platinum jaap aarts
2020-08-15 21:22 ` jaap aarts
2020-08-15 22:54 ` Barnabás Pőcze
2020-08-16  0:01   ` Guenter Roeck
2020-08-16  0:27     ` Barnabás Pőcze
2020-08-16  0:51       ` Guenter Roeck
2020-08-16  1:35         ` Barnabás Pőcze [this message]
2020-08-16  8:57   ` jaap aarts
2020-08-16  9:34 ` kernel test robot
2020-08-16  9:34   ` kernel test robot
2020-08-16  0:04 Guenter Roeck
2020-08-16  9:05 ` jaap aarts

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='jXVNMOMJ1nqEEhjQbWGsgeGm0TWaNDSHsp-YOtCWb-Sx3NqjIEGQKjUzA8FuUgvwXijS-fUWIfokZ--M3aCZUusFduP_EHXyaiMIfdPguQY=@protonmail.com' \
    --to=pobrn@protonmail.com \
    --cc=jaap.aarts1@gmail.com \
    --cc=jdelvare@suse.com \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=linux@roeck-us.net \
    /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.