tools: env: Pass through indent
Pass tools/env/fw_env.c through indent to correct style violations. This commit consists of only one non-whitespace change: tools/env/fw_env.c:549: error: do not use assignment in if condition Signed-off-by: Alex Kiernan <alex.kiernan@gmail.com>
This commit is contained in:
parent
5c643db4cc
commit
c7f52c4b6e
1 changed files with 170 additions and 176 deletions
58
tools/env/fw_env.c
vendored
58
tools/env/fw_env.c
vendored
|
@ -64,14 +64,14 @@ struct envdev_s {
|
||||||
int is_ubi; /* set if we use UBI volume */
|
int is_ubi; /* set if we use UBI volume */
|
||||||
};
|
};
|
||||||
|
|
||||||
static struct envdev_s envdevices[2] =
|
static struct envdev_s envdevices[2] = {
|
||||||
{
|
|
||||||
{
|
{
|
||||||
.mtd_type = MTD_ABSENT,
|
.mtd_type = MTD_ABSENT,
|
||||||
}, {
|
}, {
|
||||||
.mtd_type = MTD_ABSENT,
|
.mtd_type = MTD_ABSENT,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
static int dev_current;
|
static int dev_current;
|
||||||
|
|
||||||
#define DEVNAME(i) envdevices[(i)].devname
|
#define DEVNAME(i) envdevices[(i)].devname
|
||||||
|
@ -515,15 +515,13 @@ int fw_env_flush(struct env_opts *opts)
|
||||||
|
|
||||||
/* write environment back to flash */
|
/* write environment back to flash */
|
||||||
if (flash_io(O_RDWR)) {
|
if (flash_io(O_RDWR)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr, "Error: can't write fw_env to flash\n");
|
||||||
"Error: can't write fw_env to flash\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Set/Clear a single variable in the environment.
|
* Set/Clear a single variable in the environment.
|
||||||
* This is called in sequence to update the environment
|
* This is called in sequence to update the environment
|
||||||
|
@ -548,7 +546,8 @@ int fw_env_write(char *name, char *value)
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((oldval = envmatch (name, env)) != NULL)
|
oldval = envmatch(name, env);
|
||||||
|
if (oldval)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -615,7 +614,8 @@ int fw_env_write(char *name, char *value)
|
||||||
/*
|
/*
|
||||||
* Append new definition at the end
|
* Append new definition at the end
|
||||||
*/
|
*/
|
||||||
for (env = environment.data; *env || *(env + 1); ++env);
|
for (env = environment.data; *env || *(env + 1); ++env)
|
||||||
|
;
|
||||||
if (env > environment.data)
|
if (env > environment.data)
|
||||||
++env;
|
++env;
|
||||||
/*
|
/*
|
||||||
|
@ -628,8 +628,7 @@ int fw_env_write(char *name, char *value)
|
||||||
|
|
||||||
if (len > (&environment.data[ENV_SIZE] - env)) {
|
if (len > (&environment.data[ENV_SIZE] - env)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Error: environment overflow, \"%s\" deleted\n",
|
"Error: environment overflow, \"%s\" deleted\n", name);
|
||||||
name);
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -807,7 +806,6 @@ int fw_parse_script(char *fname, struct env_opts *opts)
|
||||||
else
|
else
|
||||||
val = NULL;
|
val = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Setting %s : %s\n",
|
fprintf(stderr, "Setting %s : %s\n",
|
||||||
name, val ? val : " removed");
|
name, val ? val : " removed");
|
||||||
|
@ -928,8 +926,7 @@ static int flash_read_buf (int dev, int fd, void *buf, size_t count,
|
||||||
|
|
||||||
if (blockstart + block_seek + readlen > environment_end(dev)) {
|
if (blockstart + block_seek + readlen > environment_end(dev)) {
|
||||||
/* End of range is reached */
|
/* End of range is reached */
|
||||||
fprintf (stderr,
|
fprintf(stderr, "Too few good blocks within range\n");
|
||||||
"Too few good blocks within range\n");
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1109,7 +1106,6 @@ static int flash_write_buf(int dev, int fd, void *buf, size_t count)
|
||||||
DEVNAME(dev), strerror(errno));
|
DEVNAME(dev), strerror(errno));
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Write 0x%llx bytes at 0x%llx\n",
|
fprintf(stderr, "Write 0x%llx bytes at 0x%llx\n",
|
||||||
(unsigned long long)erasesize,
|
(unsigned long long)erasesize,
|
||||||
|
@ -1251,8 +1247,7 @@ static int flash_io (int mode)
|
||||||
if (fd_target < 0) {
|
if (fd_target < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Can't open %s: %s\n",
|
"Can't open %s: %s\n",
|
||||||
DEVNAME (dev_target),
|
DEVNAME(dev_target), strerror(errno));
|
||||||
strerror (errno));
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
goto exit;
|
goto exit;
|
||||||
}
|
}
|
||||||
|
@ -1263,8 +1258,7 @@ static int flash_io (int mode)
|
||||||
|
|
||||||
rc = flash_write(fd_current, fd_target, dev_target);
|
rc = flash_write(fd_current, fd_target, dev_target);
|
||||||
|
|
||||||
if (fsync(fd_current) &&
|
if (fsync(fd_current) && !(errno == EINVAL || errno == EROFS)) {
|
||||||
!(errno == EINVAL || errno == EROFS)) {
|
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"fsync failed on %s: %s\n",
|
"fsync failed on %s: %s\n",
|
||||||
DEVNAME(dev_current), strerror(errno));
|
DEVNAME(dev_current), strerror(errno));
|
||||||
|
@ -1281,8 +1275,7 @@ static int flash_io (int mode)
|
||||||
if (close(fd_target)) {
|
if (close(fd_target)) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"I/O error on %s: %s\n",
|
"I/O error on %s: %s\n",
|
||||||
DEVNAME (dev_target),
|
DEVNAME(dev_target), strerror(errno));
|
||||||
strerror (errno));
|
|
||||||
rc = -1;
|
rc = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1362,7 +1355,8 @@ int fw_env_open(struct env_opts *opts)
|
||||||
if (!crc0_ok) {
|
if (!crc0_ok) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: Bad CRC, using default environment\n");
|
"Warning: Bad CRC, using default environment\n");
|
||||||
memcpy(environment.data, default_environment, sizeof default_environment);
|
memcpy(environment.data, default_environment,
|
||||||
|
sizeof(default_environment));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
flag0 = *environment.flags;
|
flag0 = *environment.flags;
|
||||||
|
@ -1424,7 +1418,7 @@ int fw_env_open(struct env_opts *opts)
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Warning: Bad CRC, using default environment\n");
|
"Warning: Bad CRC, using default environment\n");
|
||||||
memcpy(environment.data, default_environment,
|
memcpy(environment.data, default_environment,
|
||||||
sizeof default_environment);
|
sizeof(default_environment));
|
||||||
dev_current = 0;
|
dev_current = 0;
|
||||||
} else {
|
} else {
|
||||||
switch (environment.flag_scheme) {
|
switch (environment.flag_scheme) {
|
||||||
|
@ -1518,15 +1512,13 @@ static int check_device_config(int dev)
|
||||||
fd = open(DEVNAME(dev), O_RDONLY);
|
fd = open(DEVNAME(dev), O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"Cannot open %s: %s\n",
|
"Cannot open %s: %s\n", DEVNAME(dev), strerror(errno));
|
||||||
DEVNAME(dev), strerror(errno));
|
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
rc = fstat(fd, &st);
|
rc = fstat(fd, &st);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "Cannot stat the file %s\n",
|
fprintf(stderr, "Cannot stat the file %s\n", DEVNAME(dev));
|
||||||
DEVNAME(dev));
|
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1571,14 +1563,16 @@ static int check_device_config(int dev)
|
||||||
if (DEVOFFSET(dev) < 0) {
|
if (DEVOFFSET(dev) < 0) {
|
||||||
rc = ioctl(fd, BLKGETSIZE64, &size);
|
rc = ioctl(fd, BLKGETSIZE64, &size);
|
||||||
if (rc < 0) {
|
if (rc < 0) {
|
||||||
fprintf(stderr, "Could not get block device size on %s\n",
|
fprintf(stderr,
|
||||||
|
"Could not get block device size on %s\n",
|
||||||
DEVNAME(dev));
|
DEVNAME(dev));
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEVOFFSET(dev) = DEVOFFSET(dev) + size;
|
DEVOFFSET(dev) = DEVOFFSET(dev) + size;
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
fprintf(stderr, "Calculated device offset 0x%llx on %s\n",
|
fprintf(stderr,
|
||||||
|
"Calculated device offset 0x%llx on %s\n",
|
||||||
DEVOFFSET(dev), DEVNAME(dev));
|
DEVOFFSET(dev), DEVNAME(dev));
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
@ -1589,13 +1583,15 @@ static int check_device_config(int dev)
|
||||||
ENVSECTORS(dev) = DIV_ROUND_UP(ENVSIZE(dev), DEVESIZE(dev));
|
ENVSECTORS(dev) = DIV_ROUND_UP(ENVSIZE(dev), DEVESIZE(dev));
|
||||||
|
|
||||||
if (DEVOFFSET(dev) % DEVESIZE(dev) != 0) {
|
if (DEVOFFSET(dev) % DEVESIZE(dev) != 0) {
|
||||||
fprintf(stderr, "Environment does not start on (erase) block boundary\n");
|
fprintf(stderr,
|
||||||
|
"Environment does not start on (erase) block boundary\n");
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ENVSIZE(dev) > ENVSECTORS(dev) * DEVESIZE(dev)) {
|
if (ENVSIZE(dev) > ENVSECTORS(dev) * DEVESIZE(dev)) {
|
||||||
fprintf(stderr, "Environment does not fit into available sectors\n");
|
fprintf(stderr,
|
||||||
|
"Environment does not fit into available sectors\n");
|
||||||
errno = EINVAL;
|
errno = EINVAL;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
@ -1695,9 +1691,7 @@ static int get_config (char *fname)
|
||||||
rc = sscanf(dump, "%ms %lli %lx %lx %lx",
|
rc = sscanf(dump, "%ms %lli %lx %lx %lx",
|
||||||
&devname,
|
&devname,
|
||||||
&DEVOFFSET(i),
|
&DEVOFFSET(i),
|
||||||
&ENVSIZE(i),
|
&ENVSIZE(i), &DEVESIZE(i), &ENVSECTORS(i));
|
||||||
&DEVESIZE(i),
|
|
||||||
&ENVSECTORS(i));
|
|
||||||
|
|
||||||
if (rc < 3)
|
if (rc < 3)
|
||||||
continue;
|
continue;
|
||||||
|
|
Loading…
Reference in a new issue