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