aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCyril Bur <cyril.bur@au1.ibm.com>2016-10-11 18:51:21 +1100
committerStewart Smith <stewart@linux.vnet.ibm.com>2016-10-17 10:33:58 +1100
commit52a001404edadff9a36d83b371bb15d247115d5b (patch)
tree72c8047208b8ae3c635d8eb2281bdc52d8848523
parentb0f1134d467bdf0f8799c9f31452142c51065bca (diff)
downloadskiboot-52a001404edadff9a36d83b371bb15d247115d5b.zip
skiboot-52a001404edadff9a36d83b371bb15d247115d5b.tar.gz
skiboot-52a001404edadff9a36d83b371bb15d247115d5b.tar.bz2
external/pflash: Reduce variable scope as indicated by cppcheck
Signed-off-by: Cyril Bur <cyril.bur@au1.ibm.com> Signed-off-by: Stewart Smith <stewart@linux.vnet.ibm.com>
-rw-r--r--external/pflash/pflash.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/external/pflash/pflash.c b/external/pflash/pflash.c
index 73eb916..bece12a 100644
--- a/external/pflash/pflash.c
+++ b/external/pflash/pflash.c
@@ -304,8 +304,7 @@ static void set_ecc(uint32_t start, uint32_t size)
static void program_file(const char *file, uint32_t start, uint32_t size)
{
- int fd, rc;
- ssize_t len;
+ int fd;
uint32_t actual_size = 0;
fd = open(file, O_RDONLY);
@@ -326,6 +325,9 @@ static void program_file(const char *file, uint32_t start, uint32_t size)
printf("Programming & Verifying...\n");
progress_init(size >> 8);
while(size) {
+ ssize_t len;
+ int rc;
+
len = read(fd, file_buf, FILE_BUF_SIZE);
if (len < 0) {
perror("Error reading file");
@@ -362,8 +364,7 @@ static void program_file(const char *file, uint32_t start, uint32_t size)
static void do_read_file(const char *file, uint32_t start, uint32_t size)
{
- int fd, rc;
- ssize_t len;
+ int fd;
uint32_t done = 0;
fd = open(file, O_WRONLY | O_TRUNC | O_CREAT, 00666);
@@ -376,6 +377,9 @@ static void do_read_file(const char *file, uint32_t start, uint32_t size)
progress_init(size >> 8);
while(size) {
+ ssize_t len;
+ int rc;
+
len = size > FILE_BUF_SIZE ? FILE_BUF_SIZE : size;
rc = blocklevel_read(bl, start, file_buf, len);
if (rc) {