[libvirt PATCH 02/17] util: Simplify stubs

Andrea Bolognani posted 17 patches 4 years, 11 months ago
[libvirt PATCH 02/17] util: Simplify stubs
Posted by Andrea Bolognani 4 years, 11 months ago
Calling a stub should always result in ENOSYS being raised,
regardless of what arguments are passed to it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
---
 src/util/virprocess.c | 22 ++++++----------------
 1 file changed, 6 insertions(+), 16 deletions(-)

diff --git a/src/util/virprocess.c b/src/util/virprocess.c
index 9fe75d54d6..e01ff25540 100644
--- a/src/util/virprocess.c
+++ b/src/util/virprocess.c
@@ -850,11 +850,8 @@ virProcessGetMaxMemLock(pid_t pid,
 #else /* ! (WITH_GETRLIMIT && defined(RLIMIT_MEMLOCK)) */
 int
 virProcessGetMaxMemLock(pid_t pid G_GNUC_UNUSED,
-                        unsigned long long *bytes)
+                        unsigned long long *bytes G_GNUC_UNUSED)
 {
-    if (!bytes)
-        return 0;
-
     virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
     return -1;
 }
@@ -900,11 +897,9 @@ virProcessSetMaxProcesses(pid_t pid, unsigned int procs)
 }
 #else /* ! (WITH_SETRLIMIT && defined(RLIMIT_NPROC)) */
 int
-virProcessSetMaxProcesses(pid_t pid G_GNUC_UNUSED, unsigned int procs)
+virProcessSetMaxProcesses(pid_t pid G_GNUC_UNUSED,
+                          unsigned int procs G_GNUC_UNUSED)
 {
-    if (procs == 0)
-        return 0;
-
     virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
     return -1;
 }
@@ -957,11 +952,9 @@ virProcessSetMaxFiles(pid_t pid, unsigned int files)
 }
 #else /* ! (WITH_SETRLIMIT && defined(RLIMIT_NOFILE)) */
 int
-virProcessSetMaxFiles(pid_t pid G_GNUC_UNUSED, unsigned int files)
+virProcessSetMaxFiles(pid_t pid G_GNUC_UNUSED,
+                      unsigned int files G_GNUC_UNUSED)
 {
-    if (files == 0)
-        return 0;
-
     virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
     return -1;
 }
@@ -1004,11 +997,8 @@ virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes)
 #else /* ! (WITH_SETRLIMIT && defined(RLIMIT_CORE)) */
 int
 virProcessSetMaxCoreSize(pid_t pid G_GNUC_UNUSED,
-                         unsigned long long bytes)
+                         unsigned long long bytes G_GNUC_UNUSED)
 {
-    if (bytes == 0)
-        return 0;
-
     virReportSystemError(ENOSYS, "%s", _("Not supported on this platform"));
     return -1;
 }
-- 
2.26.2

Re: [libvirt PATCH 02/17] util: Simplify stubs
Posted by Michal Privoznik 4 years, 11 months ago
On 3/5/21 8:13 PM, Andrea Bolognani wrote:
> Calling a stub should always result in ENOSYS being raised,
> regardless of what arguments are passed to it.
> 
> Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> ---
>   src/util/virprocess.c | 22 ++++++----------------
>   1 file changed, 6 insertions(+), 16 deletions(-)

Missed virProcessSetMaxMemLock().

Michal

Re: [libvirt PATCH 02/17] util: Simplify stubs
Posted by Andrea Bolognani 4 years, 11 months ago
On Mon, 2021-03-08 at 11:31 +0100, Michal Privoznik wrote:
> On 3/5/21 8:13 PM, Andrea Bolognani wrote:
> > Calling a stub should always result in ENOSYS being raised,
> > regardless of what arguments are passed to it.
> > 
> > Signed-off-by: Andrea Bolognani <abologna@redhat.com>
> > ---
> >   src/util/virprocess.c | 22 ++++++----------------
> >   1 file changed, 6 insertions(+), 16 deletions(-)
> 
> Missed virProcessSetMaxMemLock().

Good catch - I must have misplaced it during a rebase O:-)

-- 
Andrea Bolognani / Red Hat / Virtualization