Message ID | 20200609162639.14788-3-sde@unmatched.eu |
---|---|
State | Changes Requested |
Headers | show |
Series | [1/4] Add semver library | expand |
Hi Stji, On 09.06.20 18:26, Stijn Devriendt wrote: > Signed-off-by: Stijn Devriendt <sde@unmatched.eu> > --- > core/artifacts_versions.c | 6 ++++++ > core/swupdate.c | 3 +++ > parser/parser.c | 4 ++++ > 3 files changed, 13 insertions(+) > > diff --git a/core/artifacts_versions.c b/core/artifacts_versions.c > index 6fe5d60..d7be3ce 100644 > --- a/core/artifacts_versions.c > +++ b/core/artifacts_versions.c > @@ -25,6 +25,7 @@ > #include "swupdate.h" > #include "parselib.h" > #include "swupdate_settings.h" > +#include "semver.h" > > /* > * Read versions of components from a file, if provided > @@ -66,6 +67,9 @@ static int read_sw_version_file(struct swupdate_cfg *sw) > } > strlcpy(swcomp->name, name, sizeof(swcomp->name)); > strlcpy(swcomp->version, version, sizeof(swcomp->version)); > + > + semver_clean(swcomp->version); > + But semver_clean() returns an int, and her eis ignored. As far as I see, semver_clean() could be changed to return a void, as it just checks for lenght. If not, return code must be always be checked in SWUpdate. > LIST_INSERT_HEAD(&sw->installed_sw_list, swcomp, next); > TRACE("Installed %s: Version %s", > swcomp->name, > @@ -118,6 +122,8 @@ static int versions_settings(void *setting, void *data) > GET_FIELD_STRING(LIBCFG_PARSER, elem, "name", swcomp->name); > GET_FIELD_STRING(LIBCFG_PARSER, elem, "version", swcomp->version); > > + semver_clean(swcomp->version); > + > LIST_INSERT_HEAD(&sw->installed_sw_list, swcomp, next); > TRACE("Installed %s: Version %s", > swcomp->name, > diff --git a/core/swupdate.c b/core/swupdate.c > index 74dfbbe..565f76b 100644 > --- a/core/swupdate.c > +++ b/core/swupdate.c > @@ -47,6 +47,7 @@ > #include "swupdate_settings.h" > #include "pctl.h" > #include "state.h" > +#include "semver.h" > > #ifdef CONFIG_SYSTEMD > #include <systemd/sd-daemon.h> > @@ -792,11 +793,13 @@ int main(int argc, char **argv) > swcfg.globals.no_downgrading = 1; > strlcpy(swcfg.globals.minimum_version, optarg, > sizeof(swcfg.globals.minimum_version)); > + semver_clean(swcfg.globals.minimum_version); > break; > case 'R': > swcfg.globals.no_reinstalling = 1; > strlcpy(swcfg.globals.current_version, optarg, > sizeof(swcfg.globals.current_version)); > + semver_clean(swcfg.globals.current_version); > break; > case 'M': > swcfg.globals.no_transaction_marker = 1; > diff --git a/parser/parser.c b/parser/parser.c > index 31efe46..3a2d826 100644 > --- a/parser/parser.c > +++ b/parser/parser.c > @@ -24,6 +24,7 @@ > #include "parsers.h" > #include "swupdate_dict.h" > #include "lua_util.h" > +#include "semver.h" > > #define MODULE_NAME "PARSER" > > @@ -273,6 +274,9 @@ static int parse_common_attributes(parsertype p, void *elem, struct img_type *im > > GET_FIELD_STRING(p, elem, "name", image->id.name); > GET_FIELD_STRING(p, elem, "version", image->id.version); > + > + semver_clean(image->id.version); > + > GET_FIELD_STRING(p, elem, "filename", image->fname); > GET_FIELD_STRING(p, elem, "path", image->path); > GET_FIELD_STRING(p, elem, "volume", image->volname); > Best regards, Stefano Babic
diff --git a/core/artifacts_versions.c b/core/artifacts_versions.c index 6fe5d60..d7be3ce 100644 --- a/core/artifacts_versions.c +++ b/core/artifacts_versions.c @@ -25,6 +25,7 @@ #include "swupdate.h" #include "parselib.h" #include "swupdate_settings.h" +#include "semver.h" /* * Read versions of components from a file, if provided @@ -66,6 +67,9 @@ static int read_sw_version_file(struct swupdate_cfg *sw) } strlcpy(swcomp->name, name, sizeof(swcomp->name)); strlcpy(swcomp->version, version, sizeof(swcomp->version)); + + semver_clean(swcomp->version); + LIST_INSERT_HEAD(&sw->installed_sw_list, swcomp, next); TRACE("Installed %s: Version %s", swcomp->name, @@ -118,6 +122,8 @@ static int versions_settings(void *setting, void *data) GET_FIELD_STRING(LIBCFG_PARSER, elem, "name", swcomp->name); GET_FIELD_STRING(LIBCFG_PARSER, elem, "version", swcomp->version); + semver_clean(swcomp->version); + LIST_INSERT_HEAD(&sw->installed_sw_list, swcomp, next); TRACE("Installed %s: Version %s", swcomp->name, diff --git a/core/swupdate.c b/core/swupdate.c index 74dfbbe..565f76b 100644 --- a/core/swupdate.c +++ b/core/swupdate.c @@ -47,6 +47,7 @@ #include "swupdate_settings.h" #include "pctl.h" #include "state.h" +#include "semver.h" #ifdef CONFIG_SYSTEMD #include <systemd/sd-daemon.h> @@ -792,11 +793,13 @@ int main(int argc, char **argv) swcfg.globals.no_downgrading = 1; strlcpy(swcfg.globals.minimum_version, optarg, sizeof(swcfg.globals.minimum_version)); + semver_clean(swcfg.globals.minimum_version); break; case 'R': swcfg.globals.no_reinstalling = 1; strlcpy(swcfg.globals.current_version, optarg, sizeof(swcfg.globals.current_version)); + semver_clean(swcfg.globals.current_version); break; case 'M': swcfg.globals.no_transaction_marker = 1; diff --git a/parser/parser.c b/parser/parser.c index 31efe46..3a2d826 100644 --- a/parser/parser.c +++ b/parser/parser.c @@ -24,6 +24,7 @@ #include "parsers.h" #include "swupdate_dict.h" #include "lua_util.h" +#include "semver.h" #define MODULE_NAME "PARSER" @@ -273,6 +274,9 @@ static int parse_common_attributes(parsertype p, void *elem, struct img_type *im GET_FIELD_STRING(p, elem, "name", image->id.name); GET_FIELD_STRING(p, elem, "version", image->id.version); + + semver_clean(image->id.version); + GET_FIELD_STRING(p, elem, "filename", image->fname); GET_FIELD_STRING(p, elem, "path", image->path); GET_FIELD_STRING(p, elem, "volume", image->volname);
Signed-off-by: Stijn Devriendt <sde@unmatched.eu> --- core/artifacts_versions.c | 6 ++++++ core/swupdate.c | 3 +++ parser/parser.c | 4 ++++ 3 files changed, 13 insertions(+)