diff mbox

[U-Boot,4/8] net/tftp.c: cosmetic: do not use assignment in if condition

Message ID 1305388203-22983-5-git-send-email-luca.ceresoli@comelit.it
State Accepted
Commit 2cb53608076381e2cc4472790a0d768717d01b32
Headers show

Commit Message

Luca Ceresoli May 14, 2011, 3:49 p.m. UTC
This removes the following checkpatch issue:
 - ERROR: do not use assignment in if condition.

There is one such error left:

  ERROR: do not use assignment in if condition
  #239: FILE: tftp.c:239:
  +		if (!ProhibitMcast
  +		 && (Bitmap = malloc(Mapsize))
  +		 && eth_get_dev()->mcast) {

which would require an additional nested if to be fixed, resulting in longer
and less readable code.

Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
Cc: Wolfgang Denk <wd@denx.de>
---
 net/tftp.c |   18 ++++++++++++------
 1 files changed, 12 insertions(+), 6 deletions(-)

Comments

Wolfgang Denk May 19, 2011, 7:36 p.m. UTC | #1
Dear Luca Ceresoli,

In message <1305388203-22983-5-git-send-email-luca.ceresoli@comelit.it> you wrote:
> This removes the following checkpatch issue:
>  - ERROR: do not use assignment in if condition.
> 
> There is one such error left:
> 
>   ERROR: do not use assignment in if condition
>   #239: FILE: tftp.c:239:
>   +		if (!ProhibitMcast
>   +		 && (Bitmap = malloc(Mapsize))
>   +		 && eth_get_dev()->mcast) {
> 
> which would require an additional nested if to be fixed, resulting in longer
> and less readable code.
> 
> Signed-off-by: Luca Ceresoli <luca.ceresoli@comelit.it>
> Cc: Wolfgang Denk <wd@denx.de>
> ---
>  net/tftp.c |   18 ++++++++++++------
>  1 files changed, 12 insertions(+), 6 deletions(-)

Applied, thanks.

Best regards,

Wolfgang Denk
diff mbox

Patch

diff --git a/net/tftp.c b/net/tftp.c
index 4c05266..81b7aa5 100644
--- a/net/tftp.c
+++ b/net/tftp.c
@@ -552,10 +552,12 @@  TftpStart(void)
 	 * Allow the user to choose TFTP blocksize and timeout.
 	 * TFTP protocol has a minimal timeout of 1 second.
 	 */
-	if ((ep = getenv("tftpblocksize")) != NULL)
+	ep = getenv("tftpblocksize");
+	if (ep != NULL)
 		TftpBlkSizeOption = simple_strtol(ep, NULL, 10);
 
-	if ((ep = getenv("tftptimeout")) != NULL)
+	ep = getenv("tftptimeout");
+	if (ep != NULL)
 		TftpTimeoutMSecs = simple_strtol(ep, NULL, 10);
 
 	if (TftpTimeoutMSecs < 1000) {
@@ -635,10 +637,12 @@  TftpStart(void)
 	TftpOurPort = 1024 + (get_timer(0) % 3072);
 
 #ifdef CONFIG_TFTP_PORT
-	if ((ep = getenv("tftpdstp")) != NULL) {
+	ep = getenv("tftpdstp");
+	if (ep != NULL) {
 		TftpServerPort = simple_strtol(ep, NULL, 10);
 	}
-	if ((ep = getenv("tftpsrcp")) != NULL) {
+	ep = getenv("tftpsrcp");
+	if (ep != NULL) {
 		TftpOurPort = simple_strtol(ep, NULL, 10);
 	}
 #endif
@@ -721,7 +725,8 @@  static void parse_multicast_oack(char *pkt, int len)
 		/* I malloc instead of pre-declare; so that if the file ends
 		 * up being too big for this bitmap I can retry
 		 */
-		if (!(Bitmap = malloc(Mapsize))) {
+		Bitmap = malloc(Mapsize);
+		if (!Bitmap) {
 			printf("No Bitmap, no multicast. Sorry.\n");
 			ProhibitMcast = 1;
 			return;
@@ -734,7 +739,8 @@  static void parse_multicast_oack(char *pkt, int len)
 	if (Mcast_addr != addr) {
 		if (Mcast_addr)
 			eth_mcast_join(Mcast_addr, 0);
-		if (eth_mcast_join(Mcast_addr = addr, 1)) {
+		Mcast_addr = addr;
+		if (eth_mcast_join(Mcast_addr, 1)) {
 			printf("Fail to set mcast, revert to TFTP\n");
 			ProhibitMcast = 1;
 			mcast_cleanup();