From: Jan Kiszka <
jan.k...@siemens.com>
Further cppcheck findings, but all harmless ones.
Signed-off-by: Jan Kiszka <
jan.k...@siemens.com>
---
env/env_api.c | 2 +-
tools/ebgpart.c | 12 ++++++------
tools/tests/test_probe_config_file.c | 26 +++++++++++++-------------
3 files changed, 20 insertions(+), 20 deletions(-)
diff --git a/env/env_api.c b/env/env_api.c
index 4fa759d..3e39084 100644
--- a/env/env_api.c
+++ b/env/env_api.c
@@ -148,7 +148,7 @@ uint16_t ebg_env_getglobalstate(ebgenv_t *e)
/* find all environments with revision 0 */
for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
- BGENV *env = bgenv_open_by_index(i);
+ env = bgenv_open_by_index(i);
if (!env) {
continue;
diff --git a/tools/ebgpart.c b/tools/ebgpart.c
index fc3bf3b..5607465 100644
--- a/tools/ebgpart.c
+++ b/tools/ebgpart.c
@@ -393,13 +393,13 @@ static int scan_devdir(unsigned int fmajor, unsigned int fminor, char *fullname,
}
(void)snprintf(fullname, maxlen, "%s/%s", DEVDIR,
devfile->d_name);
- struct stat fstat;
- if (stat(fullname, &fstat) == -1) {
+ struct stat statbuf;
+ if (stat(fullname, &statbuf) == -1) {
VERBOSE(stderr, "stat failed on %s\n", fullname);
break;
}
- if (major(fstat.st_rdev) == fmajor &&
- minor(fstat.st_rdev) == fminor) {
+ if (major(statbuf.st_rdev) == fmajor &&
+ minor(statbuf.st_rdev) == fminor) {
VERBOSE(stdout, "Node found: %s\n", fullname);
result = 0;
break;
@@ -462,8 +462,8 @@ void ped_device_probe_all(void)
/* Check if this file is really in the dev directory */
(void)snprintf(fullname, sizeof(fullname), "%s/%s", DEVDIR,
sysblockfile->d_name);
- struct stat fstat;
- if (stat(fullname, &fstat) == -1) {
+ struct stat statbuf;
+ if (stat(fullname, &statbuf) == -1) {
/* Node with same name not found in /dev, thus search
* for node with identical Major and Minor revision */
if (scan_devdir(fmajor, fminor, fullname,
diff --git a/tools/tests/test_probe_config_file.c b/tools/tests/test_probe_config_file.c
index 439d5d4..fb5055b 100644
--- a/tools/tests/test_probe_config_file.c
+++ b/tools/tests/test_probe_config_file.c
@@ -48,40 +48,40 @@ STAILQ_HEAD(stailhead, fake_env_file_path) head = STAILQ_HEAD_INITIALIZER(head);
char *get_mountpoint_custom_fake(char *devpath)
{
char *buff = NULL;
- char *tmpdir = NULL;
- char *tmpfile = NULL;
+ char *tempdir = NULL;
+ char *tempfile = NULL;
- if (asprintf(&tmpdir, "%s", fake_mountpoint) == -1) {
- tmpdir = NULL;
+ if (asprintf(&tempdir, "%s", fake_mountpoint) == -1) {
+ tempdir = NULL;
goto fake_mountpoint_error;
}
- tmpdir = mkdtemp(tmpdir);
- if (!tmpdir) {
+ tempdir = mkdtemp(tempdir);
+ if (!tempdir) {
goto fake_mountpoint_error;
}
- if (asprintf(&buff, "%s", tmpdir) == -1) {
+ if (asprintf(&buff, "%s", tempdir) == -1) {
buff = NULL;
goto fake_mountpoint_error;
}
- if (asprintf(&tmpfile, "%s/%s", tmpdir, FAT_ENV_FILENAME) == -1) {
- tmpfile = NULL;
+ if (asprintf(&tempfile, "%s/%s", tempdir, FAT_ENV_FILENAME) == -1) {
+ tempfile = NULL;
goto fake_mountpoint_error;
}
/* create a fake environment file
*/
- FILE *temp_env_file = fopen(tmpfile, "w");
+ FILE *temp_env_file = fopen(tempfile, "w");
BG_ENVDATA env_data;
memset(&env_data, 0, sizeof(BG_ENVDATA));
fwrite(&env_data, sizeof(BG_ENVDATA), 1, temp_env_file);
fclose(temp_env_file);
- free(tmpfile);
- free(tmpdir);
+ free(tempfile);
+ free(tempdir);
struct fake_env_file_path *fefp;
fefp = malloc(sizeof(struct fake_env_file_path));
@@ -103,7 +103,7 @@ char *get_mountpoint_custom_fake(char *devpath)
fake_mountpoint_error:
free(fefp);
free(buff);
- free(tmpdir);
+ free(tempdir);
return NULL;
}
--
2.26.2