mirror of
https://github.com/moparisthebest/pacman
synced 2024-12-22 15:58:50 -05:00
Fix a few problems reported by clang-analyzer
One missing NULL-check and 3 dead assignments. Signed-off-by: Xavier Chantry <chantry.xavier@gmail.com> Signed-off-by: Dan McGee <dan@archlinux.org>
This commit is contained in:
parent
0e39cf9275
commit
c2cce1f46a
@ -54,7 +54,6 @@ void *_package_changelog_open(pmpkg_t *pkg)
|
|||||||
struct archive *archive = NULL;
|
struct archive *archive = NULL;
|
||||||
struct archive_entry *entry;
|
struct archive_entry *entry;
|
||||||
const char *pkgfile = pkg->origin_data.file;
|
const char *pkgfile = pkg->origin_data.file;
|
||||||
int ret = ARCHIVE_OK;
|
|
||||||
|
|
||||||
if((archive = archive_read_new()) == NULL) {
|
if((archive = archive_read_new()) == NULL) {
|
||||||
RET_ERR(PM_ERR_LIBARCHIVE, NULL);
|
RET_ERR(PM_ERR_LIBARCHIVE, NULL);
|
||||||
@ -68,7 +67,7 @@ void *_package_changelog_open(pmpkg_t *pkg)
|
|||||||
RET_ERR(PM_ERR_PKG_OPEN, NULL);
|
RET_ERR(PM_ERR_PKG_OPEN, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
while((ret = archive_read_next_header(archive, &entry)) == ARCHIVE_OK) {
|
while(archive_read_next_header(archive, &entry) == ARCHIVE_OK) {
|
||||||
const char *entry_name = archive_entry_pathname(entry);
|
const char *entry_name = archive_entry_pathname(entry);
|
||||||
|
|
||||||
if(strcmp(entry_name, ".CHANGELOG") == 0) {
|
if(strcmp(entry_name, ".CHANGELOG") == 0) {
|
||||||
|
@ -129,7 +129,6 @@ int _alpm_sync_db_populate(pmdb_t *db)
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
struct archive *archive;
|
struct archive *archive;
|
||||||
struct archive_entry *entry;
|
struct archive_entry *entry;
|
||||||
const char * archive_path;
|
|
||||||
|
|
||||||
ALPM_LOG_FUNC;
|
ALPM_LOG_FUNC;
|
||||||
|
|
||||||
@ -156,8 +155,6 @@ int _alpm_sync_db_populate(pmdb_t *db)
|
|||||||
st = archive_entry_stat(entry);
|
st = archive_entry_stat(entry);
|
||||||
|
|
||||||
if(S_ISDIR(st->st_mode)) {
|
if(S_ISDIR(st->st_mode)) {
|
||||||
archive_path = archive_entry_pathname(entry);
|
|
||||||
|
|
||||||
pkg = _alpm_pkg_new();
|
pkg = _alpm_pkg_new();
|
||||||
if(pkg == NULL) {
|
if(pkg == NULL) {
|
||||||
archive_read_finish(archive);
|
archive_read_finish(archive);
|
||||||
@ -204,7 +201,7 @@ int _alpm_sync_db_populate(pmdb_t *db)
|
|||||||
int _alpm_sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entry *entry)
|
int _alpm_sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entry *entry)
|
||||||
{
|
{
|
||||||
char line[1024];
|
char line[1024];
|
||||||
const char *entryname;
|
const char *entryname = NULL;
|
||||||
char *filename, *pkgname, *p, *q;
|
char *filename, *pkgname, *p, *q;
|
||||||
pmpkg_t *pkg;
|
pmpkg_t *pkg;
|
||||||
|
|
||||||
@ -214,13 +211,14 @@ int _alpm_sync_db_read(pmdb_t *db, struct archive *archive, struct archive_entry
|
|||||||
RET_ERR(PM_ERR_DB_NULL, -1);
|
RET_ERR(PM_ERR_DB_NULL, -1);
|
||||||
}
|
}
|
||||||
|
|
||||||
if(entry == NULL) {
|
if(entry != NULL) {
|
||||||
|
entryname = archive_entry_pathname(entry);
|
||||||
|
}
|
||||||
|
if(entryname == NULL) {
|
||||||
_alpm_log(PM_LOG_DEBUG, "invalid archive entry provided to _alpm_sync_db_read, skipping\n");
|
_alpm_log(PM_LOG_DEBUG, "invalid archive entry provided to _alpm_sync_db_read, skipping\n");
|
||||||
return(-1);
|
return(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
entryname = archive_entry_pathname(entry);
|
|
||||||
|
|
||||||
_alpm_log(PM_LOG_FUNCTION, "loading package data from archive entry %s\n",
|
_alpm_log(PM_LOG_FUNCTION, "loading package data from archive entry %s\n",
|
||||||
entryname);
|
entryname);
|
||||||
|
|
||||||
|
@ -651,7 +651,6 @@ void print_packages(const alpm_list_t *packages)
|
|||||||
string = strreplace(temp, "%s", size);
|
string = strreplace(temp, "%s", size);
|
||||||
free(size);
|
free(size);
|
||||||
free(temp);
|
free(temp);
|
||||||
temp = string;
|
|
||||||
}
|
}
|
||||||
printf("%s\n",string);
|
printf("%s\n",string);
|
||||||
free(string);
|
free(string);
|
||||||
|
Loading…
Reference in New Issue
Block a user