public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH -next 0/3] media: Remove unnecessary ternary operators
@ 2023-08-04  3:13 Ruan Jinjie
  2023-08-04  3:13 ` [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator Ruan Jinjie
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Ruan Jinjie @ 2023-08-04  3:13 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, j.neuschaefer, u.kleine-koenig,
	linux-media
  Cc: ruanjinjie

Ther are a little ternary operators, the true or false judgement
of which is unnecessary in C language semantics.

Ruan Jinjie (3):
  media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator
  media: radio-wl1273: Remove an unnecessary ternary operator
  media: dvb-usb: gp8psk: Remove an unnecessary ternary operator

 drivers/media/dvb-frontends/drx39xyj/drxj.c | 2 +-
 drivers/media/radio/radio-wl1273.c          | 2 +-
 drivers/media/usb/dvb-usb/gp8psk.c          | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

-- 
2.34.1


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator
  2023-08-04  3:13 [PATCH -next 0/3] media: Remove unnecessary ternary operators Ruan Jinjie
@ 2023-08-04  3:13 ` Ruan Jinjie
  2023-08-04  6:05   ` Uwe Kleine-König
  2023-08-04  3:13 ` [PATCH -next 2/3] media: radio-wl1273: " Ruan Jinjie
  2023-08-04  3:13 ` [PATCH -next 3/3] media: dvb-usb: gp8psk: " Ruan Jinjie
  2 siblings, 1 reply; 7+ messages in thread
From: Ruan Jinjie @ 2023-08-04  3:13 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, j.neuschaefer, u.kleine-koenig,
	linux-media
  Cc: ruanjinjie

There is a ternary operator, the true or false judgement of which
is unnecessary in C language semantics.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
 drivers/media/dvb-frontends/drx39xyj/drxj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
index 68f4e8b5a0ab..e54e61c3518a 100644
--- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
+++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
@@ -4779,7 +4779,7 @@ set_frequency(struct drx_demod_instance *demod,
 	bool image_to_select;
 	s32 fm_frequency_shift = 0;
 
-	rf_mirror = (ext_attr->mirror == DRX_MIRROR_YES) ? true : false;
+	rf_mirror = ext_attr->mirror == DRX_MIRROR_YES;
 	tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;
 	/*
 	   Program frequency shifter
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH -next 2/3] media: radio-wl1273: Remove an unnecessary ternary operator
  2023-08-04  3:13 [PATCH -next 0/3] media: Remove unnecessary ternary operators Ruan Jinjie
  2023-08-04  3:13 ` [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator Ruan Jinjie
@ 2023-08-04  3:13 ` Ruan Jinjie
  2023-08-14  8:23   ` Jonathan Neuschäfer
  2023-08-04  3:13 ` [PATCH -next 3/3] media: dvb-usb: gp8psk: " Ruan Jinjie
  2 siblings, 1 reply; 7+ messages in thread
From: Ruan Jinjie @ 2023-08-04  3:13 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, j.neuschaefer, u.kleine-koenig,
	linux-media
  Cc: ruanjinjie

There is a ternary operator, the true or false judgement of which
is unnecessary in C language semantics.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
 drivers/media/radio/radio-wl1273.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
index e8166eac9efe..f6b98c304b72 100644
--- a/drivers/media/radio/radio-wl1273.c
+++ b/drivers/media/radio/radio-wl1273.c
@@ -1020,7 +1020,7 @@ static int wl1273_fm_set_rds(struct wl1273_device *radio, unsigned int new_mode)
 	}
 
 	if (!r)
-		radio->rds_on = (new_mode == WL1273_RDS_ON) ? true : false;
+		radio->rds_on = new_mode == WL1273_RDS_ON;
 
 	return r;
 }
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* [PATCH -next 3/3] media: dvb-usb: gp8psk: Remove an unnecessary ternary operator
  2023-08-04  3:13 [PATCH -next 0/3] media: Remove unnecessary ternary operators Ruan Jinjie
  2023-08-04  3:13 ` [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator Ruan Jinjie
  2023-08-04  3:13 ` [PATCH -next 2/3] media: radio-wl1273: " Ruan Jinjie
@ 2023-08-04  3:13 ` Ruan Jinjie
  2 siblings, 0 replies; 7+ messages in thread
From: Ruan Jinjie @ 2023-08-04  3:13 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, j.neuschaefer, u.kleine-koenig,
	linux-media
  Cc: ruanjinjie

There is a ternary operator, the true or false judgement of which
is unnecessary in C language semantics.

Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
---
 drivers/media/usb/dvb-usb/gp8psk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/media/usb/dvb-usb/gp8psk.c b/drivers/media/usb/dvb-usb/gp8psk.c
index b2b27a86dfe5..4cd21bb8805e 100644
--- a/drivers/media/usb/dvb-usb/gp8psk.c
+++ b/drivers/media/usb/dvb-usb/gp8psk.c
@@ -287,7 +287,7 @@ static int gp8psk_frontend_attach(struct dvb_usb_adapter *adap)
 	int id = le16_to_cpu(d->udev->descriptor.idProduct);
 	int is_rev1;
 
-	is_rev1 = (id == USB_PID_GENPIX_8PSK_REV_1_WARM) ? true : false;
+	is_rev1 = id == USB_PID_GENPIX_8PSK_REV_1_WARM;
 
 	adap->fe_adap[0].fe = dvb_attach(gp8psk_fe_attach,
 					 &gp8psk_fe_ops, d, is_rev1);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator
  2023-08-04  3:13 ` [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator Ruan Jinjie
@ 2023-08-04  6:05   ` Uwe Kleine-König
  2023-08-04  6:18     ` Ruan Jinjie
  0 siblings, 1 reply; 7+ messages in thread
From: Uwe Kleine-König @ 2023-08-04  6:05 UTC (permalink / raw)
  To: Ruan Jinjie; +Cc: mchehab, hverkuil-cisco, j.neuschaefer, linux-media

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

On Fri, Aug 04, 2023 at 11:13:21AM +0800, Ruan Jinjie wrote:
> There is a ternary operator, the true or false judgement of which
> is unnecessary in C language semantics.
> 
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> ---
>  drivers/media/dvb-frontends/drx39xyj/drxj.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> index 68f4e8b5a0ab..e54e61c3518a 100644
> --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
> +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
> @@ -4779,7 +4779,7 @@ set_frequency(struct drx_demod_instance *demod,
>  	bool image_to_select;
>  	s32 fm_frequency_shift = 0;
>  
> -	rf_mirror = (ext_attr->mirror == DRX_MIRROR_YES) ? true : false;
> +	rf_mirror = ext_attr->mirror == DRX_MIRROR_YES;
>  	tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;

Maybe also do:

-	tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;
+	tuner_mirror = !demod->my_common_attr->mirror_freq_spect;

?

Best regards
Uwe

>  	/*
>  	   Program frequency shifter

-- 
Pengutronix e.K.                           | Uwe Kleine-König            |
Industrial Linux Solutions                 | https://www.pengutronix.de/ |

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator
  2023-08-04  6:05   ` Uwe Kleine-König
@ 2023-08-04  6:18     ` Ruan Jinjie
  0 siblings, 0 replies; 7+ messages in thread
From: Ruan Jinjie @ 2023-08-04  6:18 UTC (permalink / raw)
  To: Uwe Kleine-König; +Cc: mchehab, hverkuil-cisco, j.neuschaefer, linux-media



On 2023/8/4 14:05, Uwe Kleine-König wrote:
> On Fri, Aug 04, 2023 at 11:13:21AM +0800, Ruan Jinjie wrote:
>> There is a ternary operator, the true or false judgement of which
>> is unnecessary in C language semantics.
>>
>> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
>> ---
>>  drivers/media/dvb-frontends/drx39xyj/drxj.c | 2 +-
>>  1 file changed, 1 insertion(+), 1 deletion(-)
>>
>> diff --git a/drivers/media/dvb-frontends/drx39xyj/drxj.c b/drivers/media/dvb-frontends/drx39xyj/drxj.c
>> index 68f4e8b5a0ab..e54e61c3518a 100644
>> --- a/drivers/media/dvb-frontends/drx39xyj/drxj.c
>> +++ b/drivers/media/dvb-frontends/drx39xyj/drxj.c
>> @@ -4779,7 +4779,7 @@ set_frequency(struct drx_demod_instance *demod,
>>  	bool image_to_select;
>>  	s32 fm_frequency_shift = 0;
>>  
>> -	rf_mirror = (ext_attr->mirror == DRX_MIRROR_YES) ? true : false;
>> +	rf_mirror = ext_attr->mirror == DRX_MIRROR_YES;
>>  	tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;
> 
> Maybe also do:
> 
> -	tuner_mirror = demod->my_common_attr->mirror_freq_spect ? false : true;
> +	tuner_mirror = !demod->my_common_attr->mirror_freq_spect;
> 
> ?

Right!

> 
> Best regards
> Uwe
> 
>>  	/*
>>  	   Program frequency shifter
> 

^ permalink raw reply	[flat|nested] 7+ messages in thread

* Re: [PATCH -next 2/3] media: radio-wl1273: Remove an unnecessary ternary operator
  2023-08-04  3:13 ` [PATCH -next 2/3] media: radio-wl1273: " Ruan Jinjie
@ 2023-08-14  8:23   ` Jonathan Neuschäfer
  0 siblings, 0 replies; 7+ messages in thread
From: Jonathan Neuschäfer @ 2023-08-14  8:23 UTC (permalink / raw)
  To: Ruan Jinjie
  Cc: mchehab, hverkuil-cisco, j.neuschaefer, u.kleine-koenig,
	linux-media

[-- Attachment #1: Type: text/plain, Size: 876 bytes --]

On Fri, Aug 04, 2023 at 11:13:22AM +0800, Ruan Jinjie wrote:
> There is a ternary operator, the true or false judgement of which
> is unnecessary in C language semantics.
> 
> Signed-off-by: Ruan Jinjie <ruanjinjie@huawei.com>
> ---
>  drivers/media/radio/radio-wl1273.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/media/radio/radio-wl1273.c b/drivers/media/radio/radio-wl1273.c
> index e8166eac9efe..f6b98c304b72 100644
> --- a/drivers/media/radio/radio-wl1273.c
> +++ b/drivers/media/radio/radio-wl1273.c
> @@ -1020,7 +1020,7 @@ static int wl1273_fm_set_rds(struct wl1273_device *radio, unsigned int new_mode)
>  	}
>  
>  	if (!r)
> -		radio->rds_on = (new_mode == WL1273_RDS_ON) ? true : false;
> +		radio->rds_on = new_mode == WL1273_RDS_ON;

Reviewed-by: Jonathan Neuschäfer <j.neuschaefer@gmx.net>

Thanks.

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2023-08-14  8:37 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-08-04  3:13 [PATCH -next 0/3] media: Remove unnecessary ternary operators Ruan Jinjie
2023-08-04  3:13 ` [PATCH -next 1/3] media: dvb-frontends: drx39xyj: Remove an unnecessary ternary operator Ruan Jinjie
2023-08-04  6:05   ` Uwe Kleine-König
2023-08-04  6:18     ` Ruan Jinjie
2023-08-04  3:13 ` [PATCH -next 2/3] media: radio-wl1273: " Ruan Jinjie
2023-08-14  8:23   ` Jonathan Neuschäfer
2023-08-04  3:13 ` [PATCH -next 3/3] media: dvb-usb: gp8psk: " Ruan Jinjie

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox