summaryrefslogtreecommitdiff
path: root/glnx-errors.h
Commit message (Collapse)AuthorAgeFilesLines
* Declare copyright and licensing using REUSESimon McVittie2022-02-191-0/+1
| | | | | | | | | | | | | | To fill in some gaps, I've had to make some assumptions: * trivial changes (such as checking for an additional function or header file in libglnx.m4) are assumed to not be copyrightable * Will Thompson and Matthew Leeds are assumed to be contributing on behalf of Endless Mobile Inc. * files with no explicit licensing information are assumed to be under the license found in COPYING Reference: https://reuse.software/ Signed-off-by: Simon McVittie <smcv@debian.org>
* errors: don't use 'static inline' on varargs functionsWill Thompson2017-11-021-66/+3
| | | | | | | | | | | | | This caused GCC 6.3.0 -Winline to complain: ../../../ext/libglnx/glnx-errors.h:169:1: warning: function ‘glnx_throw_errno_prefix’ can never be inlined because it uses variable argument lists [-Winline] glnx_throw_errno_prefix (GError **error, const char *fmt, ...) ^~~~~~~~~~~~~~~~~~~~~~~ ../../../ext/libglnx/glnx-errors.h:169:1: warning: inlining failed in call to ‘glnx_throw_errno_prefix’: function not inlinable [-Winline]
* errors: check for an error before prefixingJonathan Lebon2017-07-211-2/+3
| | | | | | Minor tweak to the new `GLNX_AUTO_PREFIX_ERROR`. Since the common case is that there's no errors, let's bring down the same check that `g_prefix_error` does to avoid a function call most of the time.
* errors: Mark GLNX_AUTO_PREFIX_ERROR() as usedColin Walters2017-07-201-1/+2
| | | | Since it's intentional we never use it, and `clang` barfs on this (rightly).
* errors: Add GLNX_AUTO_PREFIX_ERRORColin Walters2017-07-171-0/+30
| | | | | | | | | | | | In a lot of places in ostree, we end up prefixing errors in the *caller*. Often we only have 1-2 callers, and doing the error prefixing isn't too duplicative. But there are definitely cases where it's cleaner to do the prefixing in the callee. We have functions that aren't ported to new style for this reason (they still do the prefixing in `out:`). Introduce a cleanup-oriented version of error prefixing so we can port those functions too.
* glnx-errors.h: add a glnx_throw_prefix() variantJonathan Lebon2017-05-111-3/+34
| | | | | | For completeness. It just looks much cleaner than doing the `, FALSE` trick. It also takes care of appending the ': ' for you like its errno version.
* errors: Fix legacy set_prefix_error_from_errno()Colin Walters2017-03-241-3/+1
| | | | | | | We were missing the previous automatic `: ` addition; noticed in a failing ostree test. Fix this by just calling the new API as the non-prefix case does too.
* glnx-errors.h: add glnx_null_throw[_*] variantsJonathan Lebon2017-03-231-0/+11
| | | | | | | | | | | | | | | | | | | | | | | These are equivalent to the non-null throw, except that the returned value is a NULL pointer. They can be used in functions where one wants to return a pointer. E.g.: GKeyFile *foo(GError **error) { return glnx_null_throw (error, "foobar"); } The function call redirections are wrapped around a compound statement expression[1] so that they represent a single top-level expression. This allows us to avoid -Wunused-value warnings vs using a comma operator if the return value isn't used. I made the 'args...' absorb the fmt argument as well so that callers can still use it without always having to specify at least one additional variadic argument. I had to check to be sure that the expansion is all done by the preprocessor, so we don't need to worry about stack intricacies. [1] https://gcc.gnu.org/onlinedocs/gcc/Statement-Exprs.html
* errors: Add glnx_throw() and testsColin Walters2017-03-221-0/+25
| | | | | | | | Following up to the previous commit, also shorten our use of `g_set_error (..., G_IO_ERROR_FAILED, ...)`. There's a lot of this in libostree at least. See also https://bugzilla.gnome.org/show_bug.cgi?id=774061
* errors: Add new glnx_throw_errno{,_prefix}() APIsColin Walters2017-03-221-14/+65
| | | | | | | | | | | | | | | | | | | | We have a *lot* of code of the form: ``` if (unlinkat (fd, pathname) < 0) { glnx_set_error_from_errno (error); goto out; } ``` After conversion to `return FALSE style` which is in progress, it's way shorter, and clearer like this: ``` if (unlinkat (fd, pathname) < 0) return glnx_throw_errno (error); ```
* Fix includes when relying on backported g_autoptr()Matthew Barnes2015-02-181-1/+1
|
* Import directory iteration, errno handling, and shutil from libgsystemColin Walters2015-02-151-0/+49