mirror of
https://github.com/moparisthebest/pacman
synced 2025-01-10 13:28:12 -05:00
Make some small changes recommended by splint
Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
b2501950c7
commit
2f0de317b8
@ -30,29 +30,29 @@
|
||||
|
||||
config_t *config_new(void)
|
||||
{
|
||||
config_t *config = calloc(1, sizeof(config_t));
|
||||
if(!config) {
|
||||
config_t *newconfig = calloc(1, sizeof(config_t));
|
||||
if(!newconfig) {
|
||||
fprintf(stderr, "malloc failure: could not allocate %d bytes\n",
|
||||
sizeof(config_t));
|
||||
}
|
||||
/* defaults which may get overridden later */
|
||||
config->op = PM_OP_MAIN;
|
||||
config->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
|
||||
newconfig->op = PM_OP_MAIN;
|
||||
newconfig->logmask = PM_LOG_ERROR | PM_LOG_WARNING;
|
||||
/* CONFFILE is defined at compile-time */
|
||||
config->configfile = strdup(CONFFILE);
|
||||
newconfig->configfile = strdup(CONFFILE);
|
||||
|
||||
return(config);
|
||||
return(newconfig);
|
||||
}
|
||||
|
||||
int config_free(config_t *config)
|
||||
int config_free(config_t *oldconfig)
|
||||
{
|
||||
if(config == NULL) {
|
||||
if(oldconfig == NULL) {
|
||||
return(-1);
|
||||
}
|
||||
|
||||
free(config->configfile);
|
||||
free(config);
|
||||
config = NULL;
|
||||
free(oldconfig->configfile);
|
||||
free(oldconfig);
|
||||
oldconfig = NULL;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
@ -82,7 +82,7 @@ enum {
|
||||
};
|
||||
|
||||
config_t *config_new(void);
|
||||
int config_free(config_t *config);
|
||||
int config_free(config_t *oldconfig);
|
||||
|
||||
#endif /* _PM_CONF_H */
|
||||
|
||||
|
@ -153,7 +153,7 @@ static int query_search(alpm_list_t *targets)
|
||||
/* print the package size with the output if ShowSize option set */
|
||||
if(config->showsize) {
|
||||
/* Convert byte size to MB */
|
||||
double mbsize = alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
|
||||
double mbsize = (double)alpm_pkg_get_size(pkg) / (1024.0 * 1024.0);
|
||||
|
||||
printf(" [%.2f MB]", mbsize);
|
||||
}
|
||||
@ -168,10 +168,11 @@ static int query_search(alpm_list_t *targets)
|
||||
indentprint(alpm_pkg_get_desc(pkg), 4);
|
||||
printf("\n");
|
||||
}
|
||||
/* we only want to free if the list was a search list */
|
||||
if(freelist) {
|
||||
alpm_list_free(searchlist);
|
||||
}
|
||||
|
||||
/* we only want to free if the list was a search list */
|
||||
if(freelist) {
|
||||
alpm_list_free(searchlist);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
@ -195,8 +196,9 @@ static int query_group(alpm_list_t *targets)
|
||||
}
|
||||
} else {
|
||||
for(i = targets; i; i = alpm_list_next(i)) {
|
||||
pmgrp_t *grp;
|
||||
package = alpm_list_getdata(i);
|
||||
pmgrp_t *grp = alpm_db_readgrp(db_local, package);
|
||||
grp = alpm_db_readgrp(db_local, package);
|
||||
if(grp) {
|
||||
const alpm_list_t *p, *pkgnames = alpm_grp_get_pkgs(grp);
|
||||
for(p = pkgnames; p; p = alpm_list_next(p)) {
|
||||
@ -236,8 +238,8 @@ static int query_test(void)
|
||||
|
||||
static int query_upgrades(void)
|
||||
{
|
||||
printf(_("Checking for package upgrades... \n"));
|
||||
alpm_list_t *syncpkgs;
|
||||
printf(_("Checking for package upgrades... \n"));
|
||||
|
||||
if((syncpkgs = alpm_db_get_upgrades()) != NULL) {
|
||||
display_targets(syncpkgs);
|
||||
@ -257,8 +259,8 @@ static int is_foreign(pmpkg_t *pkg)
|
||||
int match = 0;
|
||||
for(j = sync_dbs; j; j = alpm_list_next(j)) {
|
||||
pmdb_t *db = alpm_list_getdata(j);
|
||||
pmpkg_t *pkg = alpm_db_get_pkg(db, pkgname);
|
||||
if(pkg) {
|
||||
pmpkg_t *findpkg = alpm_db_get_pkg(db, pkgname);
|
||||
if(findpkg) {
|
||||
match = 1;
|
||||
break;
|
||||
}
|
||||
|
@ -27,7 +27,7 @@
|
||||
|
||||
#include <alpm.h>
|
||||
|
||||
void output_cb(pmloglevel_t level, char *fmt, va_list args)
|
||||
static void output_cb(pmloglevel_t level, char *fmt, va_list args)
|
||||
{
|
||||
if(strlen(fmt)) {
|
||||
switch(level) {
|
||||
|
Loading…
Reference in New Issue
Block a user