This is to avoid the Wflag-enum warning that Clang emits when you have a
flags enum where a multi-bit value encompasses a bit that doesn't have a
corresponding single-bit value.
(I'm not sure why G_REGEX_NEWLINE_ANYCRLF isn't just 1 << 22...)
This is to avoid the Wflag-enum warning that Clang emits when you have a
flags enum where a multi-bit value encompasses a bit that doesn't have a
corresponding single-bit value.
It can appear either after 'enum' or after the closing brace. Also handle
__attribute__((flag_enum)) and, for C++ code, [[gnu::flag_enum]] and
[[clang::flag_enum]] and various other spellings of those. If it is
present, mark the enum as a flags enum, the same as if we detected left
shifts in the values.
This expands to __attribute__((flag_enum)) if available. It is useful when
using clang-tidy to do static analysis, which will warn about code like
(GParamFlags)(G_PARAM_CONSTRUCT_ONLY | G_PARAM_READWRITE).
citing https://no-color.org/
> Command-line software which adds ANSI color to its output by default should check
> for a NO_COLOR environment variable that, when present and not an empty string
> (regardless of its value), prevents the addition of ANSI color.
This makes sure that extensions can generate code at the expected
places, and change the GDBusInterfaceSkeleton subtype that generated
skeletons derive from.
This allows us to create a copy of an argument without going through
GValue. The codegen here does not have any use for it, but we will add
an extension system in a later commit. The libdex codegen extension will
make use of it to define a boxed type for the method return values.
The out type can be different from the in types in their qualifiers and
thus are not always simply a reference to the in type. However, the out
types used to include the reference instead of the "base" type because
the code generator always used them in places where we actually needed a
reference to the out type (e.g. as out params).
For example, the codegen here generates:
gboolean dex_dbus_ping_pong_call_ping_sync (
DexDbusPingPong *proxy,
const gchar *arg_name,
gchar ** out_pong,
GCancellable *cancellable,
GError **error);
Where `gchar **` is the out type. If we want to codegen a function which
returns the out params in a struct, it would need to look like this:
typedef struct _DexDbusPingPongPingResult
{
gchar * pong;
} DexDbusPingPongPingResult;
Where neither the out type `gchar **` nor the in type `const gchar *` is
appropriate.
This changes the ctype_out to be the base type, and makes the codegen
add the reference explicitly.
Contrary to MSDN documentation, GetThreadPriority() may return
undocumented priority values that SetThreadPriority() cannot accept.
This can happen, for example, when a high-priority process uses
MMCSS to modify thread priority levels.
Since failure to update thread priority is not critical and users
can adjust it later, do not treat such failures as errors
A mount table is inherently trusted, so this isn't really a security
issue, but let's not write out of bounds. If anybody is still using GLib
on AIX, then you're welcome.
Discovery and patch credit: mhzcyber - Mohammad Hussam Alzeyyat
(I, Michael, only wrote this commit message and adjusted the
whitespace.)
This previous behavior violates RFC-1123 which updated the original
RFC-952.
Patch originally from Ulrich Drepper.
Fixes: #3523
Signed-off-by: Christian Hergert <chergert@redhat.com>
This adds the condition that a new unix address is tried only when there
is enough space to append random character(s) before the address reach
the length of UNIX_PATH_MAX.
Before this change, creating a GDBusServer with unix addresses longer
than UNIX_PATH_MAX that existed in the filesystem would never return. A
test that expects G_IO_ERROR_ADDRESS_IN_USE in such scenario was added.
The code stripped all but the first trailing slash in order to handle
the absolute root path "/". This breaks the removal of trailing slashes
for paths starting with $HOME, though.
Fix the logic to remove all trailing slashes if $HOME is encountered.
Closes#3811
The return value from `fread()` doesn’t actually indicate whether the
read failed due to EOF or due to a read error.
Rework the code so that errors are reported correctly, EOF is handled
silently, and as a byproduct, blank lines in the input file are ignored
and skipped over.
Spotted by scan-build.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Error handling in `fread()` is too complex, and the code explicitly
disables the buffering feature of `FILE`, so there’s little point in
using it.
Instead, use `open()`/`read()` directly. This avoids any buffering
issues, and gives us use of `errno` to check errors. `ferror()` doesn’t
give us any more information than “there was an error”.
This fixes an issue flagged by scan-build: that a failure in the first
`fread()` loop iteration would leave the `FILE` in an undefined state
(in particular, an undefined seek position) which would mess up the next
iteration. Since `ferror()` couldn’t actually tell us what the error was
(was it `EINTR`?) and `errno` is not guaranteed to be set by `fread()`,
the whole approach was doomed.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
If asked to replace a file (i.e. effectively delete and re-create it)
which is a symlink, in a read-only directory, the code would end up
trying to do operations on an invalid `fd`. This was masked when asked
to create a backup, as creating the backup in the read-only
directory would error out just in time.
Make the code a bit more robust in this situation, and add some unit
tests.
Spotted by scan-build.
Signed-off-by: Philip Withnall <pwithnall@gnome.org>
Rather than passing it to `dup2()`, which scan-build thinks could cause
problems (I would have thought `dup2()` would just return `EBADF`, but
perhaps some implementations are buggy?).
Signed-off-by: Philip Withnall <pwithnall@gnome.org>