linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
@ 2025-07-18 12:52 Darshan Rathod
  2025-07-19  0:45 ` kernel test robot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Darshan Rathod @ 2025-07-18 12:52 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Darshan Rathod, linux-media, linux-kernel

Function flexcop_eeprom_check_mac_addr() contains an
assignment in an 'if' condition. This coding style is not
accepted in the Linux kernel as it can conceal bugs.

Put the assignment before the 'if' condition, in an
explicit separate statement. It will also bring this code
in line with checkpatch.pl.

Also, correct a few off-by-one spaces in a function call and
variable declaration.

Signed-off-by: Darshan Rathod <darshanrathod475@gmail.com>
---
 drivers/media/common/b2c2/flexcop-eeprom.c | 18 ++++++++++--------
 1 file changed, 10 insertions(+), 8 deletions(-)

diff --git a/drivers/media/common/b2c2/flexcop-eeprom.c b/drivers/media/common/b2c2/flexcop-eeprom.c
index 0f2151cd36f2..da7c537ef93b 100644
--- a/drivers/media/common/b2c2/flexcop-eeprom.c
+++ b/drivers/media/common/b2c2/flexcop-eeprom.c
@@ -90,7 +90,7 @@ static char eeprom_set_mac_addr(struct adapter *adapter, char type, u8 *mac)
 static int flexcop_eeprom_read(struct flexcop_device *fc,
 		u16 addr, u8 *buf, u16 len)
 {
-	return fc->i2c_request(fc,FC_READ,FC_I2C_PORT_EEPROM,0x50,addr,buf,len);
+	return fc->i2c_request(fc, FC_READ, FC_I2C_PORT_EEPROM, 0x50, addr, buf, len);
 }
 
 #endif
@@ -107,7 +107,7 @@ static u8 calc_lrc(u8 *buf, int len)
 static int flexcop_eeprom_request(struct flexcop_device *fc,
 	flexcop_access_op_t op, u16 addr, u8 *buf, u16 len, int retries)
 {
-	int i,ret = 0;
+	int i, ret = 0;
 	u8 chipaddr =  0x50 | ((addr >> 8) & 3);
 	for (i = 0; i < retries; i++) {
 		ret = fc->i2c_request(&fc->fc_i2c_adap[1], op, chipaddr,
@@ -135,13 +135,15 @@ int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
 	u8 buf[8];
 	int ret = 0;
 
-	if ((ret = flexcop_eeprom_lrc_read(fc,0x3f8,buf,8,4)) == 0) {
+	ret = flexcop_eeprom_lrc_read(fc, 0x3f8, buf, 8, 4);
+
+	if (ret == 0) {
 		if (extended != 0) {
 			err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
-			ret = -EINVAL;
-		} else
-			memcpy(fc->dvb_adapter.proposed_mac,buf,6);
-	}
-	return ret;
+			ret = ret = -EINVAL;
+		} else {
+			memcpy(fc->dvb_adapter.proposed_mac, buf, 6);
+		}
+		return ret;
 }
 EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);
-- 
2.43.0


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

* Re: [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
  2025-07-18 12:52 [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition Darshan Rathod
@ 2025-07-19  0:45 ` kernel test robot
  2025-07-19  4:42 ` kernel test robot
  2025-07-19 13:50 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-07-19  0:45 UTC (permalink / raw)
  To: Darshan Rathod, Mauro Carvalho Chehab, linux-kernel
  Cc: oe-kbuild-all, linux-media

Hi Darshan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on linuxtv-media-pending/master]
[also build test WARNING on sailus-media-tree/master linus/master media-tree/master sailus-media-tree/streams v6.16-rc6 next-20250718]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Darshan-Rathod/media-b2c2-flexcop-eeprom-Fix-assignment-in-if-condition/20250718-205456
base:   https://git.linuxtv.org/media-ci/media-pending.git master
patch link:    https://lore.kernel.org/r/20250718125245.82910-1-darshanrathod475%40gmail.com
patch subject: [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
config: i386-randconfig-002-20250719 (https://download.01.org/0day-ci/archive/20250719/202507190855.RA0Awmj9-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250719/202507190855.RA0Awmj9-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507190855.RA0Awmj9-lkp@intel.com/

All warnings (new ones prefixed by >>):

   drivers/media/common/b2c2/flexcop-eeprom.c: In function 'flexcop_eeprom_check_mac_addr':
>> drivers/media/common/b2c2/flexcop-eeprom.c:143:29: warning: operation on 'ret' may be undefined [-Wsequence-point]
     143 |                         ret = ret = -EINVAL;
   drivers/media/common/b2c2/flexcop-eeprom.c:149:1: error: expected declaration or statement at end of input
     149 | EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);
         | ^~~~~~~~~~~~~
>> drivers/media/common/b2c2/flexcop-eeprom.c:150: warning: control reaches end of non-void function [-Wreturn-type]


vim +/ret +143 drivers/media/common/b2c2/flexcop-eeprom.c

   130	
   131	/* JJ's comment about extended == 1: it is not presently used anywhere but was
   132	 * added to the low-level functions for possible support of EUI64 */
   133	int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
   134	{
   135		u8 buf[8];
   136		int ret = 0;
   137	
   138		ret = flexcop_eeprom_lrc_read(fc, 0x3f8, buf, 8, 4);
   139	
   140		if (ret == 0) {
   141			if (extended != 0) {
   142				err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
 > 143				ret = ret = -EINVAL;
   144			} else {
   145				memcpy(fc->dvb_adapter.proposed_mac, buf, 6);
   146			}
   147			return ret;
   148	}
   149	EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
  2025-07-18 12:52 [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition Darshan Rathod
  2025-07-19  0:45 ` kernel test robot
@ 2025-07-19  4:42 ` kernel test robot
  2025-07-19 13:50 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2025-07-19  4:42 UTC (permalink / raw)
  To: Darshan Rathod, Mauro Carvalho Chehab, linux-kernel
  Cc: oe-kbuild-all, linux-media

Hi Darshan,

kernel test robot noticed the following build errors:

[auto build test ERROR on linuxtv-media-pending/master]
[also build test ERROR on sailus-media-tree/master linus/master media-tree/master sailus-media-tree/streams v6.16-rc6 next-20250718]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Darshan-Rathod/media-b2c2-flexcop-eeprom-Fix-assignment-in-if-condition/20250718-205456
base:   https://git.linuxtv.org/media-ci/media-pending.git master
patch link:    https://lore.kernel.org/r/20250718125245.82910-1-darshanrathod475%40gmail.com
patch subject: [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
config: i386-randconfig-002-20250719 (https://download.01.org/0day-ci/archive/20250719/202507191200.uSwaI9wh-lkp@intel.com/config)
compiler: gcc-11 (Debian 11.3.0-12) 11.3.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250719/202507191200.uSwaI9wh-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202507191200.uSwaI9wh-lkp@intel.com/

All errors (new ones prefixed by >>):

   drivers/media/common/b2c2/flexcop-eeprom.c: In function 'flexcop_eeprom_check_mac_addr':
   drivers/media/common/b2c2/flexcop-eeprom.c:143:29: warning: operation on 'ret' may be undefined [-Wsequence-point]
     143 |                         ret = ret = -EINVAL;
>> drivers/media/common/b2c2/flexcop-eeprom.c:149:1: error: expected declaration or statement at end of input
     149 | EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);
         | ^~~~~~~~~~~~~
   drivers/media/common/b2c2/flexcop-eeprom.c:150: warning: control reaches end of non-void function [-Wreturn-type]


vim +149 drivers/media/common/b2c2/flexcop-eeprom.c

2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  130  
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  131  /* JJ's comment about extended == 1: it is not presently used anywhere but was
1589a993f07412 drivers/media/dvb/b2c2/flexcop-eeprom.c    Uwe Bugla             2009-03-29  132   * added to the low-level functions for possible support of EUI64 */
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  133  int flexcop_eeprom_check_mac_addr(struct flexcop_device *fc, int extended)
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  134  {
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  135  	u8 buf[8];
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  136  	int ret = 0;
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  137  
662f3e9a140301 drivers/media/common/b2c2/flexcop-eeprom.c Darshan Rathod        2025-07-18  138  	ret = flexcop_eeprom_lrc_read(fc, 0x3f8, buf, 8, 4);
662f3e9a140301 drivers/media/common/b2c2/flexcop-eeprom.c Darshan Rathod        2025-07-18  139  
662f3e9a140301 drivers/media/common/b2c2/flexcop-eeprom.c Darshan Rathod        2025-07-18  140  	if (ret == 0) {
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  141  		if (extended != 0) {
d9942ad0228a7e drivers/media/common/b2c2/flexcop-eeprom.c Mauro Carvalho Chehab 2016-10-18  142  			err("TODO: extended (EUI64) MAC addresses aren't completely supported yet");
662f3e9a140301 drivers/media/common/b2c2/flexcop-eeprom.c Darshan Rathod        2025-07-18  143  			ret = ret = -EINVAL;
662f3e9a140301 drivers/media/common/b2c2/flexcop-eeprom.c Darshan Rathod        2025-07-18  144  		} else {
778241313819e1 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  145  			memcpy(fc->dvb_adapter.proposed_mac, buf, 6);
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  146  		}
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  147  		return ret;
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16  148  }
2add87a95068d6 drivers/media/dvb/b2c2/flexcop-eeprom.c    Johannes Stezenbach   2005-05-16 @149  EXPORT_SYMBOL(flexcop_eeprom_check_mac_addr);

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

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

* Re: [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition
  2025-07-18 12:52 [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition Darshan Rathod
  2025-07-19  0:45 ` kernel test robot
  2025-07-19  4:42 ` kernel test robot
@ 2025-07-19 13:50 ` Markus Elfring
  2 siblings, 0 replies; 4+ messages in thread
From: Markus Elfring @ 2025-07-19 13:50 UTC (permalink / raw)
  To: Darshan Rathod, linux-media; +Cc: LKML, Mauro Carvalho Chehab

> Function flexcop_eeprom_check_mac_addr() contains an
> assignment in an 'if' condition. This coding style is not
> accepted in the Linux kernel as it can conceal bugs.
…

You may occasionally put more than 60 characters into text lines
of such a change description.


> Also, correct a few off-by-one spaces in a function call and
> variable declaration.

Please split possible changes into separate update steps.
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.16-rc6#n81

Regards,
Markus

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

end of thread, other threads:[~2025-07-19 13:50 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-18 12:52 [PATCH] media: b2c2: flexcop-eeprom: Fix assignment in if condition Darshan Rathod
2025-07-19  0:45 ` kernel test robot
2025-07-19  4:42 ` kernel test robot
2025-07-19 13:50 ` Markus Elfring

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).