Projects
openEuler:22.03:LTS:LoongArch
rpm
_service:tar_scm_kernel_repo:backport-Make-rpmf...
Sign Up
Log In
Username
Password
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File _service:tar_scm_kernel_repo:backport-Make-rpmfiSetFX-return-code-meaningful.patch of Package rpm
From 318efbaec80a90f1d9ac76d0cd433f6ea3c103fa Mon Sep 17 00:00:00 2001 From: Panu Matilainen <pmatilai@redhat.com> Date: Thu, 10 Feb 2022 10:07:06 +0200 Subject: [PATCH] Make rpmfiSetFX() return code meaningful Up to now, rpmfiSetFX() has returned the previous file index on success, and -1 on error. Which seems okay on the outset, but on a just initialized iterator the file index is at -1 which means the returned -1 sometimes indicates an error and sometimes success. This is so broken that none of the callers even try to use it (grep for it). Which is lucky in the sense that it means we can change it. Simply return the newly set index on success and -1 on error, it may not be the greatest return code on earth but at least it's non-ambiguous. --- lib/rpmfi.c | 2 +- lib/rpmfi.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/rpmfi.c b/lib/rpmfi.c index 30e0738..4965aee 100644 --- a/lib/rpmfi.c +++ b/lib/rpmfi.c @@ -314,9 +314,9 @@ int rpmfiSetFX(rpmfi fi, int fx) int i = -1; if (fi != NULL && fx >= 0 && fx < rpmfilesFC(fi->files)) { - i = fi->i; fi->i = fx; fi->j = rpmfilesDI(fi->files, fi->i); + i = fi->i; } return i; } diff --git a/lib/rpmfi.h b/lib/rpmfi.h index 989582b..52310c6 100644 --- a/lib/rpmfi.h +++ b/lib/rpmfi.h @@ -39,7 +39,7 @@ int rpmfiFX(rpmfi fi); * Set current file index in file info set iterator. * @param fi file info set iterator * @param fx new file index - * @return current file index + * @return new file index, -1 on error */ int rpmfiSetFX(rpmfi fi, int fx); -- 1.8.3.1
Locations
Projects
Search
Status Monitor
Help
Open Build Service
OBS Manuals
API Documentation
OBS Portal
Reporting a Bug
Contact
Mailing List
Forums
Chat (IRC)
Twitter
Open Build Service (OBS)
is an
openSUSE project
.