[PATCH] tools: fix compile warnings

10 views
Skip to first unread message

Michael Adler

unread,
Mar 22, 2022, 10:52:26 AM3/22/22
to efibootg...@googlegroups.com, Michael Adler
This fixes errors such as the following:

147 | void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
| ^~~~~~~~ ../tools/bg_printenv.c: In function 'printenv_from_file': ../tools/bg_printenv.c:256:12: note: parameter passing for argument of type 'struct fields' changed in GCC 9.1

I would argue that the warning is harmless in this instance though.
Namely, the warning should only be relevant when building *shared objects*
which are called by code compiled with GCC < 9.1. However, bg_printenv and
bg_setenv are just binaries. Nevertheless, fixing it is trivial and
won't have any noticeable impact (I preferred to copy the struct in the
first place since it's cheaper than having the pointer indirection).

Signed-off-by: Michael Adler <michae...@siemens.com>
---
tools/bg_printenv.c | 30 +++++++++++++++---------------
tools/bg_printenv.h | 4 ++--
tools/bg_setenv.c | 6 +++---
3 files changed, 20 insertions(+), 20 deletions(-)

diff --git a/tools/bg_printenv.c b/tools/bg_printenv.c
index 40dd893..69d428b 100644
--- a/tools/bg_printenv.c
+++ b/tools/bg_printenv.c
@@ -144,13 +144,13 @@ static void dump_uservars(uint8_t *udata, bool raw)
}
}

-void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
+void dump_env(BG_ENVDATA *env, const struct fields *output_fields, bool raw)
{
char buffer[ENV_STRING_LENGTH];
if (!raw) {
fprintf(stdout, "Values:\n");
}
- if (output_fields.in_progress) {
+ if (output_fields->in_progress) {
if (raw) {
fprintf(stdout, "IN_PROGRESS=%d\n", env->in_progress);
} else {
@@ -158,7 +158,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
env->in_progress ? "yes" : "no");
}
}
- if (output_fields.revision) {
+ if (output_fields->revision) {
if (raw) {
fprintf(stdout, "REVISION=%u\n", env->revision);
} else {
@@ -166,7 +166,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
env->revision);
}
}
- if (output_fields.kernel) {
+ if (output_fields->kernel) {
char *kernelfile = str16to8(buffer, env->kernelfile);
if (raw) {
fprintf(stdout, "KERNEL=%s\n", kernelfile);
@@ -174,7 +174,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
fprintf(stdout, "kernel: %s\n", kernelfile);
}
}
- if (output_fields.kernelargs) {
+ if (output_fields->kernelargs) {
char *kernelargs = str16to8(buffer, env->kernelparams);
if (raw) {
fprintf(stdout, "KERNELARGS=%s\n", kernelargs);
@@ -182,7 +182,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
fprintf(stdout, "kernelargs: %s\n", kernelargs);
}
}
- if (output_fields.wdog_timeout) {
+ if (output_fields->wdog_timeout) {
if (raw) {
fprintf(stdout, "WATCHDOG_TIMEOUT=%u\n",
env->watchdog_timeout_sec);
@@ -191,7 +191,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
env->watchdog_timeout_sec);
}
}
- if (output_fields.ustate) {
+ if (output_fields->ustate) {
if (raw) {
fprintf(stdout, "USTATE=%u\n", env->ustate);
} else {
@@ -199,7 +199,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
(uint8_t)env->ustate, ustate2str(env->ustate));
}
}
- if (output_fields.user) {
+ if (output_fields->user) {
if (!raw) {
fprintf(stdout, "\n");
fprintf(stdout, "user variables:\n");
@@ -211,7 +211,7 @@ void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw)
}
}

-void dump_envs(struct fields output_fields, bool raw)
+void dump_envs(const struct fields *output_fields, bool raw)
{
for (int i = 0; i < ENV_NUM_CONFIG_PARTS; i++) {
if (!raw) {
@@ -230,7 +230,7 @@ void dump_envs(struct fields output_fields, bool raw)
}
}

-static void dump_latest_env(struct fields output_fields, bool raw)
+static void dump_latest_env(const struct fields *output_fields, bool raw)
{
BGENV *env = bgenv_open_latest();
if (!env) {
@@ -249,11 +249,11 @@ static void dump_env_by_index(uint32_t index, struct fields output_fields,
fprintf(stderr, "Failed to retrieve latest environment.\n");
return;
}
- dump_env(env->data, output_fields, raw);
+ dump_env(env->data, &output_fields, raw);
bgenv_close(env);
}

-static int printenv_from_file(char *envfilepath, struct fields output_fields,
+static int printenv_from_file(char *envfilepath, const struct fields *output_fields,
bool raw)
{
int success = 0;
@@ -338,7 +338,7 @@ error_t bg_printenv(int argc, char **argv)

if (common->envfilepath) {
e = printenv_from_file(common->envfilepath,
- arguments.output_fields, arguments.raw);
+ &arguments.output_fields, arguments.raw);
free(common->envfilepath);
return e;
}
@@ -353,7 +353,7 @@ error_t bg_printenv(int argc, char **argv)
if (!arguments.raw) {
fprintf(stdout, "Using latest config partition\n");
}
- dump_latest_env(arguments.output_fields, arguments.raw);
+ dump_latest_env(&arguments.output_fields, arguments.raw);
} else if (common->part_specified) {
if (!arguments.raw) {
fprintf(stdout, "Using config partition #%d\n",
@@ -362,7 +362,7 @@ error_t bg_printenv(int argc, char **argv)
dump_env_by_index(common->which_part, arguments.output_fields,
arguments.raw);
} else {
- dump_envs(arguments.output_fields, arguments.raw);
+ dump_envs(&arguments.output_fields, arguments.raw);
}

bgenv_finalize();
diff --git a/tools/bg_printenv.h b/tools/bg_printenv.h
index 309ff99..532db77 100644
--- a/tools/bg_printenv.h
+++ b/tools/bg_printenv.h
@@ -30,8 +30,8 @@ struct fields {

extern const struct fields ALL_FIELDS;

-void dump_envs(struct fields output_fields, bool raw);
-void dump_env(BG_ENVDATA *env, struct fields output_fields, bool raw);
+void dump_envs(const struct fields *output_fields, bool raw);
+void dump_env(BG_ENVDATA *env, const struct fields *output_fields, bool raw);

error_t bg_printenv(int argc, char **argv);

diff --git a/tools/bg_setenv.c b/tools/bg_setenv.c
index ee0e587..d685412 100644
--- a/tools/bg_setenv.c
+++ b/tools/bg_setenv.c
@@ -349,7 +349,7 @@ static int dumpenv_to_file(char *envfilepath, bool verbosity, bool preserve_env)

update_environment(&env, verbosity);
if (verbosity) {
- dump_env(env.data, ALL_FIELDS, false);
+ dump_env(env.data, &ALL_FIELDS, false);
}
FILE *of = fopen(envfilepath, "wb");
if (of) {
@@ -428,7 +428,7 @@ error_t bg_setenv(int argc, char **argv)
}

if (arguments.common.verbosity) {
- dump_envs(ALL_FIELDS, false);
+ dump_envs(&ALL_FIELDS, false);
}

BGENV *env_new = NULL;
@@ -492,7 +492,7 @@ error_t bg_setenv(int argc, char **argv)
if (arguments.common.verbosity) {
fprintf(stdout, "New environment data:\n");
fprintf(stdout, "---------------------\n");
- dump_env(env_new->data, ALL_FIELDS, false);
+ dump_env(env_new->data, &ALL_FIELDS, false);
}
if (!bgenv_write(env_new)) {
fprintf(stderr, "Error storing environment.\n");
--
2.35.1

Jan Kiszka

unread,
Mar 22, 2022, 12:09:31 PM3/22/22
to Michael Adler, efibootg...@googlegroups.com
Thanks, applied.

Jan

--
Siemens AG, Technology
Competence Center Embedded Linux
Reply all
Reply to author
Forward
0 new messages