Commit d3525b6bb0c39de537f0d2e79bb9ab9ad8fd8bf5
Committed by
Stefan Roese
1 parent
ab61cfb857
Exists in
smarc_8mq_lf_v2020.04
and in
17 other branches
cfi_flash: Remove assignments from if conditions
The condition in if statements should not be used for variable assignment. Instead, the assignment should be done in a separate step beforehand. Fix all instances where this occurs. Signed-off-by: Mario Six <mario.six@gdsys.cc> Signed-off-by: Stefan Roese <sr@denx.de>
Showing 1 changed file with 11 additions and 7 deletions Side-by-side Diff
drivers/mtd/cfi_flash.c
... | ... | @@ -1339,7 +1339,8 @@ |
1339 | 1339 | wp = (addr & ~(info->portwidth - 1)); |
1340 | 1340 | |
1341 | 1341 | /* handle unaligned start */ |
1342 | - if ((aln = addr - wp) != 0) { | |
1342 | + aln = addr - wp; | |
1343 | + if (aln != 0) { | |
1343 | 1344 | cword.w32 = 0; |
1344 | 1345 | p = (uchar *)wp; |
1345 | 1346 | for (i = 0; i < aln; ++i) |
... | ... | @@ -1370,7 +1371,8 @@ |
1370 | 1371 | cword.w32 = 0; |
1371 | 1372 | for (i = 0; i < info->portwidth; i++) |
1372 | 1373 | flash_add_byte(info, &cword, *src++); |
1373 | - if ((rc = flash_write_cfiword(info, wp, cword)) != 0) | |
1374 | + rc = flash_write_cfiword(info, wp, cword); | |
1375 | + if (rc != 0) | |
1374 | 1376 | return rc; |
1375 | 1377 | wp += info->portwidth; |
1376 | 1378 | cnt -= info->portwidth; |
... | ... | @@ -1381,7 +1383,8 @@ |
1381 | 1383 | i = buffered_size - (wp % buffered_size); |
1382 | 1384 | if (i > cnt) |
1383 | 1385 | i = cnt; |
1384 | - if ((rc = flash_write_cfibuffer(info, wp, src, i)) != ERR_OK) | |
1386 | + rc = flash_write_cfibuffer(info, wp, src, i); | |
1387 | + if (rc != ERR_OK) | |
1385 | 1388 | return rc; |
1386 | 1389 | i -= i & (info->portwidth - 1); |
1387 | 1390 | wp += i; |
... | ... | @@ -1397,7 +1400,8 @@ |
1397 | 1400 | cword.w32 = 0; |
1398 | 1401 | for (i = 0; i < info->portwidth; i++) |
1399 | 1402 | flash_add_byte(info, &cword, *src++); |
1400 | - if ((rc = flash_write_cfiword(info, wp, cword)) != 0) | |
1403 | + rc = flash_write_cfiword(info, wp, cword); | |
1404 | + if (rc != 0) | |
1401 | 1405 | return rc; |
1402 | 1406 | wp += info->portwidth; |
1403 | 1407 | cnt -= info->portwidth; |
... | ... | @@ -1569,9 +1573,9 @@ |
1569 | 1573 | * flash_full_status_check() to work correctly |
1570 | 1574 | */ |
1571 | 1575 | flash_write_cmd(info, sector, 0, FLASH_CMD_READ_STATUS); |
1572 | - if ((retcode = | |
1573 | - flash_full_status_check(info, sector, info->erase_blk_tout, | |
1574 | - prot ? "protect" : "unprotect")) == 0) { | |
1576 | + retcode = flash_full_status_check(info, sector, info->erase_blk_tout, | |
1577 | + prot ? "protect" : "unprotect"); | |
1578 | + if (retcode == 0) { | |
1575 | 1579 | info->protect[sector] = prot; |
1576 | 1580 | |
1577 | 1581 | /* |