Radish alpha
H
rad:z3QDZAW2FAfuLvihrhiyDC9fAD8G9
HardenedBSD Package Manager
Radicle
Git
cleanup: use fputc, use goto, and some other cleanups
rilysh committed 2 years ago
commit c254b69a4f3e2278f783c7bd9c99b2d25450e3dc
parent 3a55690
4 files changed +11 -27
modified libpkg/fetch_libcurl.c
@@ -532,5 +532,4 @@ curl_cleanup(struct pkg_repo *repo)
	if (cr->url != NULL)
		curl_url_cleanup(cr->url);
	repo->fetch_priv = NULL;
-
	return;
}
modified libpkg/fetch_libfetch.c
@@ -158,18 +158,18 @@ fetch_connect(struct pkg_repo *repo, struct url *u)
			u->port = http_current->url->port;
		}
		fetchOpts = xstring_new();
-
		fputs("i", fetchOpts->fp);
+
	        fputc('i', fetchOpts->fp);
		if (repo != NULL) {
			if ((repo->flags & REPO_FLAGS_USE_IPV4) ==
			    REPO_FLAGS_USE_IPV4)
-
				fputs("4", fetchOpts->fp);
+
				fputc('4', fetchOpts->fp);
			else if ((repo->flags & REPO_FLAGS_USE_IPV6) ==
			    REPO_FLAGS_USE_IPV6)
-
				fputs("6", fetchOpts->fp);
+
				fputc('6', fetchOpts->fp);
		}

		if (ctx.debug_level >= 4)
-
			fputs("v", fetchOpts->fp);
+
			fputc('v', fetchOpts->fp);

		opts = xstring_get(fetchOpts);
		pkg_debug(1,"Fetch: fetching from: %s://%s%s%s%s with opts \"%s\"",
modified src/upgrade.c
@@ -105,20 +105,12 @@ check_vulnerable(struct pkg_audit *audit, struct pkgdb *db, int sock)
	pkgdb_it_free(it);
	pkgdb_close(db);

-
	if (check == NULL) {
-
		pkg_audit_free(audit);
-
		pkghash_destroy(check);
-
		fclose(out);
-
		return;
-
	}
-

+
	if (check == NULL)
+
	        goto out_cleanup;

	if (pkg_audit_load(audit, NULL) != EPKG_OK) {
		warn("unable to open vulnxml file");
-
		fclose(out);
-
		pkg_audit_free(audit);
-
		pkghash_destroy(check);
-
		return;
+
	        goto out_cleanup;
	}

	pkg_drop_privileges();
@@ -127,10 +119,7 @@ check_vulnerable(struct pkg_audit *audit, struct pkgdb *db, int sock)
#ifndef PKG_COVERAGE
	if (cap_enter() < 0 && errno != ENOSYS) {
		warn("cap_enter() failed");
-
		pkg_audit_free(audit);
-
		pkghash_destroy(check);
-
		fclose(out);
-
		return;
+
		goto out_cleanup;
	}
#endif
#endif
@@ -155,6 +144,7 @@ check_vulnerable(struct pkg_audit *audit, struct pkgdb *db, int sock)
		warnx("cannot process vulnxml");
	}

+
out_cleanup:
	pkg_audit_free(audit);
	pkghash_destroy(check);
	fclose(out);
@@ -233,12 +223,8 @@ add_vulnerable_upgrades(struct pkg_jobs *jobs, struct pkgdb *db)
	fclose(in);

	while (waitpid(cld, &retcode, 0) == -1) {
-
		if (errno == EINTR) {
-
			continue;
-
		}
-
		else {
+
		if (errno != EINTR) {
			warnx("Cannot wait");
-

			return (EPKG_FATAL);
		}
	}
modified src/version.c
@@ -143,8 +143,7 @@ print_version(struct pkg *pkg, const char *source, const char *ver,
		}
	}

-
	printf("\n");
-
	return;
+
	putchar('\n');
}

static int