- 13 9月, 2019 3 次提交
-
-
由 Daniel P. Berrangé 提交于
Only a few of the _QUIET allocation macros are used. Since we're no longer reporting OOM as errors, we want to eliminate all the _QUIET variants. This starts with the easy, unused, cases. Reviewed-by: NMichal Privoznik <mprivozn@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
由 Daniel P. Berrangé 提交于
The functions are left returning an "int" to avoid an immediate big-bang cleanup. They'll simply never return anything other than 0, except for virInsertN which can still return an error if the requested insertion index is out of range. Interestingly in that case, the _QUIET function would none the less report an error. Reviewed-by: NMichal Privoznik <mprivozn@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
由 Daniel P. Berrangé 提交于
The OOM handling requires special build time options which we never enable in our CI. Even once enabled the tests are incredibly slow and typically require manual inspection of the results to weed out false positives. Since there was previous agreement to switch to abort on OOM in libvirt code, there's no point continuing to keep the unused OOM testing code. Reviewed-by: NMichal Privoznik <mprivozn@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
- 19 6月, 2019 1 次提交
-
-
由 Jonathon Jongsma 提交于
Signed-off-by: NJonathon Jongsma <jjongsma@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NJán Tomko <jtomko@redhat.com>
-
- 10 4月, 2019 1 次提交
-
-
由 Peter Krempa 提交于
Keeping them with viralloc.h forcibly pulls in the other stuff from viralloc.h into other header files. This in turn creates a mess as more and more headers pull in the 'viral' header file. If we want to make 'viralloc.h' omnipresent we should pick a different approach. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com>
-
- 06 4月, 2019 1 次提交
-
-
由 Peter Krempa 提交于
This helper has solely to do with virObjects. Move it together with other virObject stuff. This also avoids the potential problem where VIR_AUTOUNREF uses virObjectAutoUnref which is defined in virobject.h. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com>
-
- 03 4月, 2019 1 次提交
-
-
由 Peter Krempa 提交于
VIR_AUTODISPOSE_STR is similar to VIR_AUTOFREE(char *) but uses virDispose for clearing of the stored string. This patch also refactors VIR_DISPOSE to use the new helper which is used for the new macro. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com>
-
- 04 3月, 2019 2 次提交
-
-
由 Peter Krempa 提交于
Document that @func must take pointer to @type. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NJán Tomko <jtomko@redhat.com>
-
由 Peter Krempa 提交于
We'd free only the first element of the vector leaking the rest. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NErik Skultety <eskultet@redhat.com>
-
- 22 2月, 2019 1 次提交
-
-
由 Peter Krempa 提交于
The new utility macros are useful for variables we put on the stack but require some cleanup. The most prominent of those is virBuffer which is used almost exclusively in that way. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NEric Blake <eblake@redhat.com>
-
- 18 2月, 2019 1 次提交
-
-
由 Peter Krempa 提交于
Add helper for utilizing __attribute__(cleanup())) for unref-ing instances of sublasses of virObject. Signed-off-by: NPeter Krempa <pkrempa@redhat.com> Reviewed-by: NErik Skultety <eskultet@redhat.com>
-
- 14 12月, 2018 2 次提交
-
-
由 Daniel P. Berrangé 提交于
Require that all headers are guarded by a symbol named LIBVIRT_$FILENAME where $FILENAME is the uppercased filename, with all characters outside a-z changed into '_'. Note we do not use a leading __ because that is technically a namespace reserved for the toolchain. Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
由 Daniel P. Berrangé 提交于
This introduces a syntax-check script that validates header files use a common layout: /* ...copyright header... */ <one blank line> #ifndef SYMBOL # define SYMBOL ....content.... #endif /* SYMBOL */ For any file ending priv.h, before the #ifndef, we will require a guard to prevent bogus imports: #ifndef SYMBOL_ALLOW # error .... #endif /* SYMBOL_ALLOW */ <one blank line> The many mistakes this script identifies are then fixed. Signed-off-by: NDaniel P. Berrangé <berrange@redhat.com>
-
- 05 12月, 2018 1 次提交
-
-
由 Yuri Chornoivan 提交于
Signed-off-by: NYuri Chornoivan <yurchor@ukr.net> Reviewed-by: NJán Tomko <jtomko@redhat.com> Signed-off-by: NJán Tomko <jtomko@redhat.com>
-
- 14 7月, 2018 1 次提交
-
-
由 Sukrit Bhatnagar 提交于
New macros are introduced which help in adding GNU C's cleanup attribute to variable declarations. Variables declared with these macros will have their allocated memory freed automatically when they go out of scope. Signed-off-by: NSukrit Bhatnagar <skrtbhtngr@gmail.com> Reviewed-by: NErik Skultety <eskultet@redhat.com>
-
- 03 11月, 2017 1 次提交
-
-
由 Andrea Bolognani 提交于
Right-aligning backslashes when defining macros or using complex commands in Makefiles looks cute, but as soon as any changes is required to the code you end up with either distractingly broken alignment or unnecessarily big diffs where most of the changes are just pushing all backslashes a few characters to one side. Generated using $ git grep -El '[[:blank:]][[:blank:]]\\$' | \ grep -E '*\.([chx]|am|mk)$$' | \ while read f; do \ sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \ done Signed-off-by: NAndrea Bolognani <abologna@redhat.com>
-
- 20 5月, 2016 1 次提交
-
-
由 John Ferlan 提交于
Seems recent versions of Coverity have (mostly) resolved the issue using ternary operations in VIR_FREE (and now VIR_DISPOSE*) macros. So let's just remove it and if necessary handle one off issues as the arise.
-
- 18 5月, 2016 1 次提交
-
-
由 Jiri Denemark 提交于
The INPLACE variants of the VIR_APPEND macros cannot fail and they are inherently quiet.
-
- 16 5月, 2016 1 次提交
-
-
由 Peter Krempa 提交于
For a few cases where we handle secret information it's good to clear the buffers containing sensitive data before freeing them. Introduce VIR_DISPOSE, VIR_DISPOSE_N and VIR_DISPOSE_STRING that allow simple clearing fo the buffers holding sensitive information on cleanup paths.
-
- 16 7月, 2014 1 次提交
-
-
由 Eric Blake 提交于
Now that we've finally fixed all the violators, it's time to enforce that any pointer to a const object is never freed (it is aliasing some other memory, where the non-const original should be freed instead). Alas, the code still needs a normal vs. Coverity version, but at least we are still guaranteeing that the macro call evaluates its argument exactly once. I verified that we still get the following compiler warnings, which in turn halts the build thanks to -Werror on gcc (hmm, gcc 4.8.3's placement of the ^ for ?: type mismatch is a bit off, but that's not our problem): int oops1 = 0; VIR_FREE(oops1); const char *oops2 = NULL; VIR_FREE(oops2); struct blah { int dummy; } oops3; VIR_FREE(oops3); util/virauthconfig.c:159:35: error: pointer/integer type mismatch in conditional expression [-Werror] VIR_FREE(oops1); ^ util/virauthconfig.c:161:5: error: passing argument 1 of 'virFree' discards 'const' qualifier from pointer target type [-Werror] VIR_FREE(oops2); ^ In file included from util/virauthconfig.c:28:0: util/viralloc.h:79:6: note: expected 'void *' but argument is of type 'const void *' void virFree(void *ptrptr) ATTRIBUTE_NONNULL(1); ^ util/virauthconfig.c:163:35: error: type mismatch in conditional expression VIR_FREE(oops3); ^ * src/util/viralloc.h (VIR_FREE): No longer cast away const. * src/xenapi/xenapi_utils.c (xenSessionFree): Work around bogus header. Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 02 7月, 2014 1 次提交
-
-
由 Martin Kletzander 提交于
Signed-off-by: NMartin Kletzander <mkletzan@redhat.com>
-
- 18 10月, 2013 1 次提交
-
-
由 Michal Privoznik 提交于
In fact, the suffix should be _QUIET not _QUIT to stress the fact, that no OOM error is reported on error. Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
-
- 10 7月, 2013 1 次提交
-
-
由 Michal Privoznik 提交于
Similarly to VIR_STRDUP, we want the OOM error to be reported in VIR_ALLOC and friends.
-
- 08 5月, 2013 1 次提交
-
-
由 Eric Blake 提交于
VIR_APPEND_ELEMENT(array, size, elem) was not safe if the expression for 'size' had side effects. While no one in the current code base was trying to pass side effects, we might as well be robust and explicitly document our intentions. * src/util/viralloc.c (virInsertElementsN): Add special case. * src/util/viralloc.h (VIR_APPEND_ELEMENT): Use it. (VIR_ALLOC, VIR_ALLOC_N, VIR_REALLOC_N, VIR_EXPAND_N) (VIR_RESIZE_N, VIR_SHRINK_N, VIR_INSERT_ELEMENT) (VIR_DELETE_ELEMENT, VIR_ALLOC_VAR, VIR_FREE): Document which macros are safe in the presence of side effects. * docs/hacking.html.in: Document this. * HACKING: Regenerate. Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 22 3月, 2013 1 次提交
-
-
由 Michal Privoznik 提交于
If users build with --enable-test-oom configure option, they get this error saying, virAllocTest* functions are not defined within tests/testutils.c.
-
- 07 3月, 2013 1 次提交
-
-
由 Eric Blake 提交于
Make the same fix as in commit de53effe. * src/util/viralloc.h (virDeleteElementsN): Cater to old glibc.
-
- 25 2月, 2013 1 次提交
-
-
由 Laine Stump 提交于
-
- 23 1月, 2013 1 次提交
-
-
由 John Ferlan 提交于
The Coverity static analyzer was generating many false positives for the unary operation inside the VIR_FREE() definition as it was trying to evaluate the else portion of the "?:" even though the if portion was (1). Signed-off-by: NEric Blake <eblake@redhat.com>
-
- 21 12月, 2012 1 次提交
-
-
由 Daniel P. Berrange 提交于
-
- 11 12月, 2012 1 次提交
-
-
由 Laine Stump 提交于
I noticed when writing the backend functions for virNetworkUpdate that I was repeating the same sequence of memmove, VIR_REALLOC, nXXX-- (and messed up the args to memmove at least once), and had seen the same sequence in a lot of other places, so I decided to write a few utility functions/macros - see the .h file for full documentation. The intent is to reduce the number of lines of code, but more importantly to eliminate the need to check the element size and element count arithmetic every time we need to do this (I *always* make at least one mistake.) VIR_INSERT_ELEMENT: insert one element at an arbitrary index within an array of objects. The size of each object is determined automatically by the macro using sizeof(*array). The new element's contents are copied into the inserted space, then the original copy of contents are 0'ed out (if everything else was successful). Compile-time assignment and size compatibility between the array and the new element is guaranteed (see explanation below [*]) VIR_INSERT_ELEMENT_COPY: identical to VIR_INSERT_ELEMENT, except that the original contents of newelem are not cleared to 0 (i.e. a copy is made). VIR_APPEND_ELEMENT: This is just a special case of VIR_INSERT_ELEMENT that "inserts" one past the current last element. VIR_APPEND_ELEMENT_COPY: identical to VIR_APPEND_ELEMENT, except that the original contents of newelem are not cleared to 0 (i.e. a copy is made). VIR_DELETE_ELEMENT: delete one element at an arbitrary index within an array of objects. It's assumed that the element being deleted is already saved elsewhere (or cleared, if that's what is appropriate). All five of these macros have an _INPLACE variant, which skips the memory re-allocation of the array, assuming that the caller has already done it (when inserting) or will do it later (when deleting). Note that VIR_DELETE_ELEMENT* can return a failure, but only if an invalid index is given (index + amount to delete is > current array size), so in most cases you can safely ignore the return (that's why the helper function virDeleteElementsN isn't declared with ATTRIBUTE_RETURN_CHECK). A warning is logged if this ever happens, since it is surely a coding error. [*] One initial problem with the INSERT and APPEND macros was that, due to both the array pointer and newelem pointer being cast to void* when passing to virInsertElementsN(), any chance of type-checking was lost. If we were going to move in newelem with a memmove anyway, we would be no worse off for this. However, most current open-coded insert/append operations use direct struct assignment to move the new element into place (or just populate the new element directly) - thus use of the new macros would open a possibility for new usage errors that didn't exist before (e.g. accidentally sending &newelemptr rather than newelemptr - I actually did this quite a lot in my test conversions of existing code). But thanks to Eric Blake's clever thinking, I was able to modify the INSERT and APPEND macros so that they *do* check for both assignment and size compatibility of *ptr (an element in the array) and newelem (the element being copied into the new position of the array). This is done via clever use of the C89-guaranteed fact that the sizeof() operator must have *no* side effects (so an assignment inside sizeof() is checked for validity, but not actually evaluated), and the fact that virInsertElementsN has a "# of new elements" argument that we want to always be 1.
-
- 21 9月, 2012 1 次提交
-
-
由 Eric Blake 提交于
https://www.gnu.org/licenses/gpl-howto.html recommends that the 'If not, see <url>.' phrase be a separate sentence. * tests/securityselinuxhelper.c: Remove doubled line. * tests/securityselinuxtest.c: Likewise. * globally: s/; If/. If/
-
- 23 7月, 2012 1 次提交
-
-
由 Osier Yang 提交于
Per the FSF address could be changed from time to time, and GNU recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html) You should have received a copy of the GNU General Public License along with Foobar. If not, see <http://www.gnu.org/licenses/>. This patch removes the explicit FSF address, and uses above instead (of course, with inserting 'Lesser' before 'General'). Except a bunch of files for security driver, all others are changed automatically, the copyright for securify files are not complete, that's why to do it manually: src/security/security_selinux.h src/security/security_driver.h src/security/security_selinux.c src/security/security_apparmor.h src/security/security_apparmor.c src/security/security_driver.c
-
- 30 3月, 2012 1 次提交
-
-
由 Daniel P. Berrange 提交于
The code is splattered with a mix of sizeof foo sizeof (foo) sizeof(foo) Standardize on sizeof(foo) and add a syntax check rule to enforce it Signed-off-by: NDaniel P. Berrange <berrange@redhat.com>
-
- 26 4月, 2011 1 次提交
-
-
由 Eric Blake 提交于
We can exploit the fact that gcc warns about int-to-pointer conversion in ternary cond?(void*):(int) in order to prevent future mistakes of calling VIR_FREE on a scalar lvalue. For example, between commits 158ba873 and 802e2df9, we would have had this warning: cc1: warnings being treated as errors remote.c: In function 'remoteDispatchListNetworks': remote.c:3684:70: error: pointer/integer type mismatch in conditional expression There are still a number of places that malloc into a const char*; while it would probably be worth scrubbing them to use char* instead, that is a separate patch, so we have to cast away const in VIR_FREE for now. * src/util/memory.h (VIR_FREE): Make gcc warn about integers. Iteratively developed from a patch by Christophe Fergeau.
-
- 03 2月, 2011 1 次提交
-
-
由 Davidlohr Bueso 提交于
When compiling libvirt with GCC 3.4.6 the following warning is being triggered quite a lot: util/memory.h:60: warning: declaration of 'remove' shadows a global declaration /usr/include/stdio.h:175: warning: shadowed declaration is here Fix this by renaming the parameter to 'toremove'.
-
- 19 11月, 2010 2 次提交
-
-
由 Eric Blake 提交于
* src/util/memory.h (VIR_RESIZE_N): New macro. * src/util/memory.c (virResizeN): New function. * src/libvirt_private.syms: Export new helper. * docs/hacking.html.in: Document it. * HACKING: Regenerate.
-
由 Eric Blake 提交于
* src/util/memory.h (VIR_REALLOC_N): Update docs. (VIR_EXPAND_N, VIR_SHRINK_N): New macros. (virAlloc, virAllocN, virReallocN, virAllocVar, virFree): Add some gcc attributes. * src/util/memory.c (virExpandN, virShrinkN): New functions. (virReallocN): Update docs. * src/libvirt_private.syms: Export new helpers. * docs/hacking.html.in: Prefer newer interfaces over VIR_REALLOC_N, since uninitialized memory can bite us. * HACKING: Regenerate.
-
- 16 4月, 2010 1 次提交
-
-
由 Eric Blake 提交于
Regression introduced in commit 62170b99. * src/util/memory.h: Placate cppi, and fit 80 columns.
-
- 14 4月, 2010 1 次提交
-
-
由 David Allan 提交于
* This patch implements a memory allocator to obtain memory for structures whose last member is a variable length array. C99 refers to these variable length objects as structs containing flexible array members. * Fixed macro parentheses per Eric Blake
-
- 10 3月, 2010 1 次提交
-
-
由 Eric Blake 提交于
* global: patch created by running: for f in $(git ls-files '*.[ch]') ; do cppi $f > $f.t && mv $f.t $f done
-