Skip to content

Commit

Permalink
optimized
Browse files Browse the repository at this point in the history
Signed-off-by: leleliu008 <[email protected]>
  • Loading branch information
leleliu008 committed Sep 4, 2023
1 parent cd43922 commit bd0a21c
Show file tree
Hide file tree
Showing 21 changed files with 27 additions and 29 deletions.
2 changes: 1 addition & 1 deletion src/check.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ int uppm_check_if_the_given_package_is_installed(const char * packageName) {
return ret;
}

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
8 changes: 3 additions & 5 deletions src/cleanup.c
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
#include <errno.h>
#include <stdio.h>
#include <string.h>

#include <errno.h>
#include <dirent.h>

#include <unistd.h>

#include <sys/stat.h>

#include "core/rm-r.h"

#include "uppm.h"

static int uppm_cleanup_downloads(bool verbose) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down Expand Up @@ -95,7 +93,7 @@ static int uppm_cleanup_downloads(bool verbose) {
}

static int uppm_cleanup_installed(bool verbose) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/depends.c
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ int uppm_depends(const char * packageName, UPPMDependsOutputType outputType, con

////////////////////////////////////////////////////////////////

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/env.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int uppm_list_dirs(const char * installedDIR, size_t installedDIRLength,
}

int uppm_env(bool verbose) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/fetch.c
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int uppm_fetch(const char * packageName, bool verbose) {

//////////////////////////////////////////////////////////////////////////

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/formula-repo-add.c
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ int uppm_formula_repo_add(const char * formulaRepoName, const char * formulaRepo

///////////////////////////////////////////////////////////////////////////////////////

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/formula-repo-create.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int uppm_formula_repo_create(const char * formulaRepoName, const char * formulaR

///////////////////////////////////////////////////////////////////////////////////////

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/formula-repo-list.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#include "uppm.h"

int uppm_formula_repo_list(UPPMFormulaRepoList * * out) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/formula-repo-lookup.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "uppm.h"

int uppm_formula_repo_lookup(const char * formulaRepoName, UPPMFormulaRepo * * formulaRepoPP) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/formula-repo-remove.c
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ int uppm_formula_repo_remove(const char * formulaRepoName) {
return UPPM_ERROR;
}

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/generate-url-transform-sample.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "uppm.h"

int uppm_generate_url_transform_sample() {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
10 changes: 5 additions & 5 deletions src/info.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,7 @@ int uppm_info(const char * packageName, const char * key) {

uppm_formula_free(formula);
} else if (strcmp(key, "bin-fp") == 0) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down Expand Up @@ -373,7 +373,7 @@ int uppm_info(const char * packageName, const char * key) {

uppm_formula_free(formula);
} else if (strcmp(key, "installed-dir") == 0) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down Expand Up @@ -410,7 +410,7 @@ int uppm_info(const char * packageName, const char * key) {
return UPPM_ERROR_PACKAGE_IS_BROKEN;
}
} else if (strcmp(key, "installed-files") == 0) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down Expand Up @@ -487,7 +487,7 @@ int uppm_info(const char * packageName, const char * key) {
}
}
} else if (strcmp(key, "installed-receipt-path") == 0) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down Expand Up @@ -524,7 +524,7 @@ int uppm_info(const char * packageName, const char * key) {
return UPPM_ERROR_PACKAGE_IS_BROKEN;
}
} else if (strcmp(key, "installed-receipt-yaml") == 0) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/install.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ int uppm_install(const char * packageName, bool verbose) {

//////////////////////////////////////////////////////////////////////////

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/integrate.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ static int mkdir_p(const char * dir, bool verbose) {
}

int uppm_integrate_zsh_completion(const char * outputDIR, bool verbose) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/list-installed-packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include "uppm.h"

int uppm_list_the_installed_packages() {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/list-outdated-packages.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
#include "uppm.h"

int uppm_list_the_outdated__packages() {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/receipt-parse.c
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ int uppm_receipt_parse(const char * packageName, UPPMReceipt * * out) {
return ret;
}

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include "uppm.h"

int uppm_session_dir(char buf[], size_t bufSize, size_t * outSize) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int uppm_tree(const char * packageName, size_t argc, char* argv[]) {
return ret;
}

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/uninstall.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ int uppm_uninstall(const char * packageName, bool verbose) {
return ret;
}

char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down
2 changes: 1 addition & 1 deletion src/upgrade-self.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#include "uppm.h"

int uppm_upgrade_self(bool verbose) {
char uppmHomeDIR[256];
char uppmHomeDIR[256] = {0};
size_t uppmHomeDIRLength;

int ret = uppm_home_dir(uppmHomeDIR, 255, &uppmHomeDIRLength);
Expand Down

0 comments on commit bd0a21c

Please sign in to comment.