mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-23 00:08:50 -05:00
Coding style cleanups; add a null check
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
ba467779bb
commit
f2c4e7e552
@ -1265,8 +1265,9 @@ static void cl_to_log(int argc, char* argv[])
|
|||||||
size += strlen(argv[i]) + 1;
|
size += strlen(argv[i]) + 1;
|
||||||
}
|
}
|
||||||
char *cl_text = malloc(size);
|
char *cl_text = malloc(size);
|
||||||
if(!cl_text)
|
if(!cl_text) {
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
char *p = cl_text;
|
char *p = cl_text;
|
||||||
for(i = 0; i<argc-1; i++) {
|
for(i = 0; i<argc-1; i++) {
|
||||||
strcpy(p, argv[i]);
|
strcpy(p, argv[i]);
|
||||||
|
@ -60,16 +60,16 @@ static int search_path(char **filename, struct stat *bufptr)
|
|||||||
char *envpath, *envpathsplit, *path, *fullname;
|
char *envpath, *envpathsplit, *path, *fullname;
|
||||||
size_t flen;
|
size_t flen;
|
||||||
|
|
||||||
if ((envpath = getenv("PATH")) == NULL) {
|
if((envpath = getenv("PATH")) == NULL) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
if ((envpath = envpathsplit = strdup(envpath)) == NULL) {
|
if((envpath = envpathsplit = strdup(envpath)) == NULL) {
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
flen = strlen(*filename);
|
flen = strlen(*filename);
|
||||||
|
|
||||||
while ((path = strsep(&envpathsplit, ":")) != NULL) {
|
while((path = strsep(&envpathsplit, ":")) != NULL) {
|
||||||
size_t plen = strlen(path);
|
size_t plen = strlen(path);
|
||||||
|
|
||||||
/* strip the trailing slash if one exists */
|
/* strip the trailing slash if one exists */
|
||||||
@ -78,6 +78,10 @@ static int search_path(char **filename, struct stat *bufptr)
|
|||||||
}
|
}
|
||||||
|
|
||||||
fullname = malloc(plen + flen + 2);
|
fullname = malloc(plen + flen + 2);
|
||||||
|
if(!fullname) {
|
||||||
|
free(envpath);
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
sprintf(fullname, "%s/%s", path, *filename);
|
sprintf(fullname, "%s/%s", path, *filename);
|
||||||
|
|
||||||
if(lstat(fullname, bufptr) == 0) {
|
if(lstat(fullname, bufptr) == 0) {
|
||||||
@ -94,7 +98,7 @@ static int search_path(char **filename, struct stat *bufptr)
|
|||||||
|
|
||||||
static void print_query_fileowner(const char *filename, pmpkg_t *info)
|
static void print_query_fileowner(const char *filename, pmpkg_t *info)
|
||||||
{
|
{
|
||||||
if (!config->quiet) {
|
if(!config->quiet) {
|
||||||
printf(_("%s is owned by %s %s\n"), filename,
|
printf(_("%s is owned by %s %s\n"), filename,
|
||||||
alpm_pkg_get_name(info), alpm_pkg_get_version(info));
|
alpm_pkg_get_name(info), alpm_pkg_get_version(info));
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user