Skip to content

Commit

Permalink
chore(clib-package): Remove redundant nullability checks
Browse files Browse the repository at this point in the history
Since the check is done right after calling `parse_repo_{owner,version}()`,
there is no need to do that down into the function.
Besides that, if `author` was ever null, a call to `strdup(author)`
would invoke undefined behaviour.
  • Loading branch information
r10nw7fd3 authored and jwerle committed May 7, 2024
1 parent b1f455e commit d6b744f
Showing 1 changed file with 8 additions and 10 deletions.
18 changes: 8 additions & 10 deletions src/common/clib-package.c
Original file line number Diff line number Diff line change
Expand Up @@ -704,22 +704,20 @@ clib_package_new_from_slug_with_package_name(const char *slug, int verbose,

// force version number
if (pkg->version) {
if (version) {
if (0 != strcmp(version, DEFAULT_REPO_VERSION)) {
_debug("forcing version number: %s (%s)", version, pkg->version);
free(pkg->version);
pkg->version = version;
} else {
free(version);
version = NULL;
}
if (0 != strcmp(version, DEFAULT_REPO_VERSION)) {
_debug("forcing version number: %s (%s)", version, pkg->version);
free(pkg->version);
pkg->version = version;
} else {
free(version);
version = NULL;
}
} else {
pkg->version = version;
}

// force package author (don't know how this could fail)
if (author && pkg->author) {
if (pkg->author) {
if (0 != strcmp(author, pkg->author)) {
free(pkg->author);
pkg->author = author;
Expand Down

0 comments on commit d6b744f

Please sign in to comment.