]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
util: virerror: Remove virReportOOMError
authorPeter Krempa <pkrempa@redhat.com>
Wed, 24 Feb 2021 10:34:00 +0000 (11:34 +0100)
committerPeter Krempa <pkrempa@redhat.com>
Tue, 2 Mar 2021 08:50:20 +0000 (09:50 +0100)
Trying to report an OOM error is pointless since our infrastructure to
report error needs to allocate memory to report the error.

In addition our code mistakenly reported OOM errors even in cases where
a function could fail for another reason, which would make issues harder
to debug.

Remove the virReportOOMError and backend so that programmers are forced
to think about what can happen. In case when there's another failure
possible a specific error should be reported and otherwise a direct
abort() is better since the logger would abort on g_new anyways.

This patch also removes the syntas-check which forces use of
virReportOOMError instead of using VIR_ERR_NO_MEMORY with other
functions. This allows possible future use when we'd end up in a
situation where trying to recover from an OOM would make sense, such as
when attempting to allocate a massive buffer.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Laine Stump <laine@redhat.com>
build-aux/syntax-check.mk
src/libvirt_private.syms
src/util/virerror.c
src/util/virerror.h

index e51877648a0d38737bfff1e91926d38a7d99e986..e1ccb7498671a3be1d38d024b84baaefddb30cb0 100644 (file)
@@ -490,11 +490,6 @@ sc_prohibit_gettext_noop:
        halt='use N_, not gettext_noop' \
          $(_sc_search_regexp)
 
-sc_prohibit_VIR_ERR_NO_MEMORY:
-       @prohibit='\<VIR_ERR_NO_MEMORY\>' \
-       halt='use virReportOOMError, not VIR_ERR_NO_MEMORY' \
-         $(_sc_search_regexp)
-
 sc_prohibit_PATH_MAX:
        @prohibit='\<PATH_MAX\>' \
        halt='dynamically allocate paths, do not use PATH_MAX' \
@@ -1895,9 +1890,6 @@ exclude_file_name_regexp--sc_libvirt_unmarked_diagnostics = \
 
 exclude_file_name_regexp--sc_po_check = ^(docs/|src/rpc/gendispatch\.pl$$|tests/commandtest.c$$)
 
-exclude_file_name_regexp--sc_prohibit_VIR_ERR_NO_MEMORY = \
-  ^(build-aux/syntax-check\.mk|include/libvirt/virterror\.h|src/remote/remote_daemon_dispatch\.c|src/util/virerror\.c|docs/internals/oomtesting\.html\.in)$$
-
 exclude_file_name_regexp--sc_prohibit_PATH_MAX = \
        ^build-aux/syntax-check\.mk$$
 
index c921ef0dc04058511028c14232d1d283159c62c8..2a3bbdc577a05c09530048bbc6fcb5310a39b1c2 100644 (file)
@@ -2117,7 +2117,6 @@ virLastErrorPrefixMessage;
 virRaiseErrorFull;
 virRaiseErrorObject;
 virReportErrorHelper;
-virReportOOMErrorFull;
 virReportSystemErrorFull;
 virSetError;
 virSetErrorLogPriorityFunc;
index 708081414ac253f9a45ddd8dabf0fefafd5baaa5..a503cdefdc9e73920045819947da600a2193a667 100644 (file)
@@ -1358,28 +1358,6 @@ void virReportSystemErrorFull(int domcode,
     errno = save_errno;
 }
 
-/**
- * virReportOOMErrorFull:
- * @domcode: the virErrorDomain indicating where it's coming from
- * @filename: filename where error was raised
- * @funcname: function name where error was raised
- * @linenr: line number where error was raised
- *
- * Convenience internal routine called when an out of memory error is
- * detected
- */
-void virReportOOMErrorFull(int domcode,
-                           const char *filename,
-                           const char *funcname,
-                           size_t linenr)
-{
-    const char *virerr;
-
-    virerr = virErrorMsg(VIR_ERR_NO_MEMORY, NULL);
-    virRaiseErrorFull(filename, funcname, linenr,
-                      domcode, VIR_ERR_NO_MEMORY, VIR_ERR_ERROR,
-                      virerr, NULL, NULL, -1, -1, virerr, NULL);
-}
 
 /**
  * virSetErrorLogPriorityFunc:
index 9d3e40d65a815f02f4dae9253b3411ade631dede..da7d7c0afe23357fd088ad53c1b7a3deeb8690e1 100644 (file)
@@ -174,14 +174,6 @@ void virReportSystemErrorFull(int domcode,
                          "Unexpected enum value %d for %s", \
                          value, sizeof((typname)1) != 0 ? #typname : #typname);
 
-void virReportOOMErrorFull(int domcode,
-                           const char *filename,
-                           const char *funcname,
-                           size_t linenr);
-
-#define virReportOOMError() \
-    virReportOOMErrorFull(VIR_FROM_THIS, __FILE__, __FUNCTION__, __LINE__)
-
 #define virReportError(code, ...) \
     virReportErrorHelper(VIR_FROM_THIS, code, __FILE__, \
                          __FUNCTION__, __LINE__, __VA_ARGS__)