Skip to content

Commit d6b744f

Browse files
r10nw7fd3jwerle
authored andcommitted
chore(clib-package): Remove redundant nullability checks
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.
1 parent b1f455e commit d6b744f

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/common/clib-package.c

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -704,22 +704,20 @@ clib_package_new_from_slug_with_package_name(const char *slug, int verbose,
704704

705705
// force version number
706706
if (pkg->version) {
707-
if (version) {
708-
if (0 != strcmp(version, DEFAULT_REPO_VERSION)) {
709-
_debug("forcing version number: %s (%s)", version, pkg->version);
710-
free(pkg->version);
711-
pkg->version = version;
712-
} else {
713-
free(version);
714-
version = NULL;
715-
}
707+
if (0 != strcmp(version, DEFAULT_REPO_VERSION)) {
708+
_debug("forcing version number: %s (%s)", version, pkg->version);
709+
free(pkg->version);
710+
pkg->version = version;
711+
} else {
712+
free(version);
713+
version = NULL;
716714
}
717715
} else {
718716
pkg->version = version;
719717
}
720718

721719
// force package author (don't know how this could fail)
722-
if (author && pkg->author) {
720+
if (pkg->author) {
723721
if (0 != strcmp(author, pkg->author)) {
724722
free(pkg->author);
725723
pkg->author = author;

0 commit comments

Comments
 (0)