Compare commits

...
Sign in to create a new pull request.

5 commits

Author SHA1 Message Date
morganamilo
83838214b7 Remove unused variables / assignments 2024-02-09 11:24:20 +10:00
morganamilo
4baeb8e40b libalpm: print errors when unknown keys in database 2024-02-09 11:24:20 +10:00
morganamilo
18b65ec909 pacman: remove uses of atoi 2024-02-09 11:24:20 +10:00
morganamilo
45ce932fd0 pacman: check for end of string when stripping ascii escapes 2024-02-09 11:24:20 +10:00
morganamilo
da4b590bce pacman: check if pkgname is empty instead of null in progress
The progress callback always uses an empty string when there is no
pkgname. However pacman checks if the argument is null.

Check if the string is empty instead and better document what is passed
to the progress callback.
2024-02-09 11:24:20 +10:00
8 changed files with 22 additions and 8 deletions

View file

@ -1149,7 +1149,9 @@ typedef enum _alpm_progress_t {
* make take a while to complete.
* @param ctx user-provided context
* @param progress the kind of event that is progressing
* @param pkg for package operations, the name of the package being operated on
* @param pkg the name of the package being operated on. if the progress kind
* is a packae operation (add, upgrade, downgrade, reinstall, remove).
* otherwise this will be an empty string.
* @param percent the percent completion of the action
* @param howmany the total amount of items in the action
* @param current the current amount of items completed

View file

@ -837,6 +837,12 @@ static int local_db_read(alpm_pkg_t *info, int inforeq)
}
}
FREELIST(lines);
} else {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s: unknown key '%s' in sync database\n"), info->name, line);
alpm_list_t *lines = NULL;
READ_AND_STORE_ALL(lines);
FREELIST(lines);
}
}
fclose(fp);

View file

@ -251,8 +251,10 @@ static int parse_descfile(alpm_handle_t *handle, struct archive *a, alpm_pkg_t *
return -1;
}
} else {
const char *pkgname = newpkg->name ? newpkg->name : "error";
_alpm_log(handle, ALPM_LOG_ERROR, _("%s: unknown key '%s' in package description\n"), pkgname, key);
_alpm_log(handle, ALPM_LOG_DEBUG, "%s: unknown key '%s' in description file line %d\n",
newpkg->name ? newpkg->name : "error", key, linenum);
pkgname, key, linenum);
}
}
}

View file

@ -691,6 +691,11 @@ static int sync_db_read(alpm_db_t *db, struct archive *archive,
}
}
FREELIST(lines);
} else {
_alpm_log(db->handle, ALPM_LOG_ERROR, _("%s: unknown key '%s' in local database\n"), pkg->name, line);
alpm_list_t *lines = NULL;
READ_AND_STORE_ALL(lines);
FREELIST(lines);
}
}
if(ret != ARCHIVE_EOF) {

View file

@ -573,7 +573,6 @@ static int curl_check_finished_download(alpm_handle_t *handle, CURLM *curlm, CUR
case CURLE_ABORTED_BY_CALLBACK:
/* handle the interrupt accordingly */
if(dload_interrupted == ABORT_OVER_MAXFILESIZE) {
curlerr = CURLE_FILESIZE_EXCEEDED;
payload->unlink_on_fail = 1;
handle->pm_errno = ALPM_ERR_LIBCURL;
_alpm_log(handle, ALPM_LOG_ERROR,

View file

@ -589,7 +589,7 @@ void cb_progress(void *ctx, alpm_progress_t event, const char *pkgname,
} else {
if(current != prevcurrent) {
/* update always */
} else if(!pkgname || percent == prevpercent ||
} else if(pkgname[0] == '\0' || percent == prevpercent ||
get_update_timediff(0) < UPDATE_SPEED_MS) {
/* only update the progress bar when we have a package name, the
* percentage has changed, and it has been long enough. */
@ -653,7 +653,7 @@ void cb_progress(void *ctx, alpm_progress_t event, const char *pkgname,
* by the output, and then pad it accordingly so we fill the terminal.
*/
/* len = opr len + pkgname len (if available) + space + null */
len = strlen(opr) + ((pkgname) ? strlen(pkgname) : 0) + 2;
len = strlen(opr) + strlen(pkgname) + 2;
wcstr = calloc(len, sizeof(wchar_t));
/* print our strings to the alloc'ed memory */
#if defined(HAVE_SWPRINTF)

View file

@ -381,7 +381,7 @@ static int parsearg_global(int opt)
break;
case OP_ASK:
config->noask = 1;
config->ask = (unsigned int)atoi(optarg);
config->ask = (unsigned int)strtol(optarg, NULL, 10);
break;
case OP_CACHEDIR:
config->cachedirs = alpm_list_add(config->cachedirs, strdup(optarg));
@ -409,7 +409,7 @@ static int parsearg_global(int opt)
* here, error and warning are set in config_new, though perhaps a
* --quiet option will remove these later */
if(optarg) {
unsigned short debug = (unsigned short)atoi(optarg);
int debug = strtol(optarg, NULL, 10);
switch(debug) {
case 2:
config->logmask |= ALPM_LOG_FUNCTION;

View file

@ -462,7 +462,7 @@ static size_t string_length(const char *s)
int iter = 0;
for(; *s; s++) {
if(*s == '\033') {
while(*s != 'm') {
while(*s != 'm' && *s != '\0') {
s++;
}
} else {