Angel Pons has uploaded this change for review.

View Change

[WIP] ft2232_spi.c: Reduce scope of programmer param variables

These variables have a very short lifetime, so enclose them in a scope
and give them more meaningful names. Ideally, programmer params should
all be extracted before any init steps are performed.

Change-Id: I2c091d7098ea97141da90b9f8b7b60f94a1a2d3d
Signed-off-by: Angel Pons <th3fanbus@gmail.com>
---
M ft2232_spi.c
1 file changed, 22 insertions(+), 6 deletions(-)

git pull ssh://review.coreboot.org:29418/flashrom refs/changes/04/67904/1
diff --git a/ft2232_spi.c b/ft2232_spi.c
index 6d7aa6a..3391998 100644
--- a/ft2232_spi.c
+++ b/ft2232_spi.c
@@ -330,7 +330,7 @@
*/
uint32_t divisor = DEFAULT_DIVISOR;
int f;
- char *arg, *arg2;
+ char *arg;
double mpsse_clk;

uint8_t cs_bits = 0x08;
@@ -603,13 +603,15 @@
msg_perr("Unable to select channel (%s).\n", ftdi_get_error_string(&ftdic));
}

- arg = extract_programmer_param_str(cfg, "serial");
- arg2 = extract_programmer_param_str(cfg, "description");
+ {
+ char *serial = extract_programmer_param_str(cfg, "serial");
+ char *description = extract_programmer_param_str(cfg, "description");

- f = ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_type, arg2, arg);
+ f = ftdi_usb_open_desc(&ftdic, ft2232_vid, ft2232_type, description, serial);

- free(arg);
- free(arg2);
+ free(serial);
+ free(description);
+ }

if (f < 0 && f != -5) {
msg_perr("Unable to open FTDI device: %d (%s)\n", f,

To view, visit change 67904. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: flashrom
Gerrit-Branch: master
Gerrit-Change-Id: I2c091d7098ea97141da90b9f8b7b60f94a1a2d3d
Gerrit-Change-Number: 67904
Gerrit-PatchSet: 1
Gerrit-Owner: Angel Pons <th3fanbus@gmail.com>
Gerrit-MessageType: newchange