Skip to contentSkip to conversation

ARM: socfgpa: Remove redundant assignment

PATCH In review Alexander Shiyan 3 participants 11 messages Feb 16, 2014 – Mar 8, 2014

Subsystems (9)
lore
Share & tools
lore
#0 lore raw

PATCH 1/7 ARM: socfgpa: Remove redundant assignment

---
 arch/arm/mach-socfpga/include/mach/sequencer.c | 1 -
 1 file changed, 1 deletion(-)
arch/arm/mach-socfpga/include/mach/sequencer.c +0 -1
index fa955ce..6e69d1b 100644
@@ -3151,7 +3151,6 @@ static uint32_t rw_mgr_mem_calibrate_wlevel (uint32_t g, uint32_t test_bgn)
 		tmp_delay += IO_DELAY_PER_DCHAIN_TAP;
 	}
 	dtaps_per_ptap--;
-	tmp_delay = 0;
 #endif
 
 	/* starting phases */
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#1 lore raw

PATCH 2/7 boot command: Remove redundant assignment

---
 commands/boot.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
commands/boot.c +1 -1
index c4b49a9..ccf5827 100644
@@ -308,7 +308,7 @@ static int boot(const char *name)
 {
 	struct blspec *blspec;
 	struct blspec_entry *entry;
-	int ret = -ENOENT;
+	int ret;
 
 	blspec = blspec_alloc();
 	ret = bootentry_parse_one(blspec, name);
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#2 lore raw

PATCH 3/7 mtd: nand_imx: Remove redundant assignment

In reply to Alexander Shiyan
---
 drivers/mtd/nand/nand_imx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/mtd/nand/nand_imx.c +1 -1
index 6ca8911..e2aaa15 100644
@@ -518,7 +518,7 @@ static int imx_nand_correct_data_v2_v3(struct mtd_info *mtd, u_char *dat,
 	struct nand_chip *nand_chip = mtd->priv;
 	struct imx_nand_host *host = nand_chip->priv;
 	u32 ecc_stat, err;
-	int no_subpages = 1;
+	int no_subpages;
 	int ret = 0;
 	u8 ecc_bit_mask, err_limit;
 
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#3 lore raw

PATCH 4/7 spi: altera_spi: Remove redundant assignment

In reply to Alexander Shiyan
---
 drivers/spi/altera_spi.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/spi/altera_spi.c +1 -1
index 60e124f..8803d9e 100644
@@ -112,7 +112,7 @@ static void altera_spi_cs_inactive(struct spi_device *spi)
 static unsigned altera_spi_do_xfer(struct spi_device *spi, struct spi_transfer *t)
 {
 	struct altera_spi *altera_spi = container_of(spi->master, struct altera_spi, master);
-	int word_len = spi->bits_per_word;
+	int word_len;
 	unsigned retval = 0;
 	u32 txval;
 	u32 rxval;
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#4 lore raw

PATCH 5/7 USB gadget: Remove redundant assignment

In reply to Alexander Shiyan
---
 drivers/usb/gadget/composite.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/composite.c +1 -1
index 9af115e..11b6c18 100644
@@ -204,7 +204,7 @@ int __init usb_interface_id(struct usb_configuration *config,
 static int config_buf(struct usb_configuration *config,
 		enum usb_device_speed speed, void *buf, u8 type)
 {
-	struct usb_config_descriptor	*c = buf;
+	struct usb_config_descriptor	*c;
 	void				*next = buf + USB_DT_CONFIG_SIZE;
 	int				len = USB_BUFSIZ - USB_DT_CONFIG_SIZE;
 	struct usb_function		*f;
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#8 lore raw

PATCH 7/7 scripts/kwboot: Remove redundant assignment

In reply to Alexander Shiyan
---
 scripts/kwboot.c | 1 -
 1 file changed, 1 deletion(-)
scripts/kwboot.c +0 -1
index 81da3e8..e068660 100644
@@ -552,7 +552,6 @@ kwboot_mmap_image(const char *path, size_t *size, int prot)
 	void *img;
 
 	rc = -1;
-	fd = -1;
 	img = NULL;
 
 	fd = open(path, O_RDONLY);
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#5 lore raw

PATCH 6/7 lib/math.c: Fix possible crash

In reply to Alexander Shiyan

Crash can be caused if xzalloc() for "numstack" fails.

---
 lib/math.c | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)
lib/math.c +5 -7
index a4731ed..1e3ee85 100644
@@ -543,11 +543,11 @@ static arith_t evaluate_string(arith_state_t *math_state, const char *expr)
 	/* Stack of operator tokens */
 	operator *const stack = xzalloc(expr_len * sizeof(stack[0]));
 	operator *stackptr = stack;
-	arith_t result;
+	arith_t result = -1;
 
 	if (numstack == NULL || stack == NULL) {
 		errmsg = "out of memory";
-		goto err_with_custom_msg;
+		goto ret;
 	}
 
 	/* Start with a left paren */
@@ -565,7 +565,7 @@ static arith_t evaluate_string(arith_state_t *math_state, const char *expr)
 		if (arithval == '\0') {
 			if (expr == start_expr) {
 				/* Null expression */
-				numstack->val = 0;
+				result = numstack->val;
 				goto ret;
 			}
 
@@ -596,6 +596,7 @@ static arith_t evaluate_string(arith_state_t *math_state, const char *expr)
 				free(numstack->var);
 				numstack->var = NULL;
 			}
+			result = numstack->val;
 			goto ret;
 		}
 
@@ -733,7 +734,7 @@ static arith_t evaluate_string(arith_state_t *math_state, const char *expr)
 				}
 				errmsg = arith_apply(math_state, prev_op, numstack, &numstackptr);
 				if (errmsg)
-					goto err_with_custom_msg;
+					goto ret;
 			}
 			if (op == TOK_RPAREN)
 				goto err;
@@ -746,10 +747,7 @@ next: ;
 
 err:
 	errmsg = "arithmetic syntax error";
-err_with_custom_msg:
-	result = -1;
 ret:
-	result = numstack->val;
 	free(stack);
 	free(numstack);
 	math_state->errmsg = errmsg;
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#6 lore raw

Re: [PATCH 6/7] lib/math.c: Fix possible crash

Quoted 1 line · Alexander Shiyan

Crash can be caused if xzalloc() for "numstack" fails.

xzalloc doesn't fail.

Sascha

Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
maintainer
#9 lore raw
In reply to Alexander Shiyan
Quoted 1 line · Alexander Shiyan

Applied all except 6/7 which probably needs some adjustments.

Sascha

Quoted 25 lines
---
 arch/arm/mach-socfpga/include/mach/sequencer.c | 1 -
 1 file changed, 1 deletion(-)
arch/arm/mach-socfpga/include/mach/sequencer.c +0 -1
index fa955ce..6e69d1b 100644
@@ -3151,7 +3151,6 @@ static uint32_t rw_mgr_mem_calibrate_wlevel (uint32_t g, uint32_t test_bgn)
 		tmp_delay += IO_DELAY_PER_DCHAIN_TAP;
 	}
 	dtaps_per_ptap--;
-	tmp_delay = 0;
 #endif
 
 	/* starting phases */
Signature · 7 lines
1.8.3.2


_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
Signature · 9 lines
Pengutronix e.K.                           |                             |
Industrial Linux Solutions                 | http://www.pengutronix.de/  |
Peiner Str. 6-8, 31137 Hildesheim, Germany | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686           | Fax:   +49-5121-206917-5555 |

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox
#7 lore raw

Re: [PATCH 6/7] lib/math.c: Fix possible crash

In reply to Sascha Hauer
Quoted 5 lines · Sascha Hauer
Quoted 1 line · Alexander Shiyan

Crash can be caused if xzalloc() for "numstack" fails.

xzalloc doesn't fail.

Some little offtopic to this issue:

I am falling sometimes in the same trap and then it reminds me "xzalloc will occur a panic when internal malloc fails". In the world of barebox we need to think a little bit different than in the world of linux. But this is actually a behaviour what we don't want, we want to think in linux way, when you programming barebox.

On the other hand, bootloader is a bootloader and need little code and this reduce a many error branches of barebox so "xzalloc" is just a great idea.

I want to mention that, Alexander is not alone. :-)

...maybe some codestyle checkers will detected this as a missing error handling.

- Alex

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox

#10 lore raw
In reply to Sascha Hauer
Quoted 4 lines · On Mon, 17 Feb 2014 08:09:09 +0100 Sascha Hauer <[email protected]> wrote:
Quoted 1 line · Alexander Shiyan

Applied all except 6/7 which probably needs some adjustments.

It seems that the patches are lost.
I do not see them in the master branch.

Signature · 6 lines
Alexander Shiyan <[email protected]>

_______________________________________________
barebox mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/barebox