Commit Graph

4849 Commits

Author SHA1 Message Date
Colin Walters
49a5d0f6f2 gfileutils: Add missing g_free() in error path
Discovered by static analysis.

https://bugzilla.gnome.org/show_bug.cgi?id=733576
2014-07-23 07:43:41 -04:00
Simon McVittie
9060a85193 glib-init: statically assert that we have 8-bit bytes
configure.ac assumes this.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=730932
2014-07-23 09:18:43 +01:00
Simon McVittie
7269d75321 gatomic: statically assert that our assumptions hold
This code assumes that int is exactly 4 bytes, and that pointers
are either 4 or 8 bytes, on platforms with __ATOMIC_SEQ_CST.
In practice this is going to be true.

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=730932
2014-07-23 09:17:48 +01:00
Ignacio Casal Quinteiro
24d614357a gspawn-win32: do not rely on __argc and __argv global vars.
Since we are getting passed Unicode values these global vars
might not have the correct value. Instead always get the wide arguments
and convert them to utf8 to use them.

https://bugzilla.gnome.org/show_bug.cgi?id=733146
2014-07-14 08:43:17 -04:00
Gergely POLONKAI
d67813045d Fix typos in gbytes_hash and g_time_zone_find_interval docs
https://bugzilla.gnome.org/show_bug.cgi?id=733084
2014-07-14 08:39:34 -04:00
Javier Jardón
60fe7b46d2 docs: Use "Returns:" instead "Return:" 2014-07-10 17:09:30 +01:00
Tim-Philipp Müller
636cd00c21 GCond (linux): fix g_cond_wait_until() return value on timeout
It should return FALSE on timeout (and only on timeout), and
TRUE otherwise.

https://bugzilla.gnome.org/show_bug.cgi?id=731986
2014-07-09 10:59:06 -04:00
Ryan Lortie
ecf1359191 GMutex (linux): detect and report some errors
Detect the following two errors:

 - attempting to unlock a mutex that is not locked

 - attempting to clear a mutex that was not initialised or was
   initialised but is still locked

Both of these are fatal errors.  We avoid using g_error() here because
doing so would involve calls back into the GMutex code, and if things
are going off the rails then we want to avoid that.

https://bugzilla.gnome.org/show_bug.cgi?id=731986
2014-07-09 10:59:06 -04:00
Ryan Lortie
49b59e5ac4 GLib: implement GMutex natively on Linux
If we have futex(2) then we can implement GMutex natively and gain a
substantial performance increase (vs. using pthreads).

This also avoids the need to allocate an extra structure in memory when
using GMutex or GCond: we can use the structure directly.

The main reason for the increase in performance is that our
implementation can be made more simple: we don't need to support the
array of options on pthread_mutex_t (which includes the possibility, for
example, of being recursive).

The result is a ~30% improvement in uncontended cases and a much larger
increase (3 to 4 times) in contended cases for a simple testcase.

https://bugzilla.gnome.org/show_bug.cgi?id=731986
2014-07-09 10:59:06 -04:00
Dan Winship
be0b921115 Fix up failure-to-see-expected-message logging
When GLib had been told to expect message X, but then actually saw
message Y, it would log the "did not see expected message" error with
message Y's log level and domain, which makes no sense. Change it to
log with domain "GLib" and G_LOG_LEVEL_CRITICAL instead.

Also, include the expected domain in the error message, so that if
that's the reason why the expectation didn't match, you can tell that
from the error message.

Update glib/tests/testing.c for these changes; for all other test
programs in GLib and elsewhere, this change should not break any
existing tests, it should only improve the output on failure.

https://bugzilla.gnome.org/show_bug.cgi?id=727974
2014-07-09 10:48:34 -04:00
Sébastien Wilmet
97f34bacce doc: small improvement and fixes
- Add an example to g_strsplit(), like it is done for g_strsplit_set().

- GTK-Doc generates a list if a "1." is at the beginning of a line.

https://bugzilla.gnome.org/show_bug.cgi?id=732704
2014-07-04 17:03:50 +02:00
Rico Tzschichholz
46df528adf glib: Fix make dist 2014-06-30 14:46:32 +02:00
Chun-wei Fan
72de983469 valgrind.h: Disable Valgrind features on x64 Visual C++ Builds
...so that builds of GLib on x64 Visual C++ can be restored, as the build
fails in line 449 of valgrind.h as it only supports MinGW/GCC for x64
Windows and simply will not build otherwise.  Make the x64 Visual C++
builds compile again by defining NVALGRIND when GLib is being built for
Windows on x64 Visual C++.

https://bugzilla.gnome.org/show_bug.cgi?id=732465
2014-06-30 19:56:05 +08:00
Sébastien Wilmet
82352ab8e7 doc: various improvements
- g_subprocess_launcher_spawn() and spawnv(): there is no other way
  AFAIK to create a GSubprocess from a launcher. So these
  functions are not "convenience helper".

- annotate optional arguments for g_shell_parse_argv().

- other trivial fix

https://bugzilla.gnome.org/show_bug.cgi?id=732357
2014-06-29 17:57:24 +02:00
Mikhail Zabaluev
9f5afe3966 glib/tests/mainloop: Acquire the context while asserting its state
The iteration methods presume that the context is acquired.

https://bugzilla.gnome.org/show_bug.cgi?id=699132
2014-06-28 13:56:07 -04:00
Mikhail Zabaluev
c0e8f8a8db A simple test for polling on a file-like descriptor
https://bugzilla.gnome.org/show_bug.cgi?id=699132
2014-06-28 13:56:07 -04:00
Ryan Lortie
0007376128 giochannel: avoid setting uninitialised length
Our internal call to g_io_channel_read_line_backend() may return
G_IO_STATUS_ERROR, in which case two things will be true:

 - the GError will have been set (if appropriate)

 - the &got_length return value may not have been set

Since it's our convention to leave 'out' parameters untouched in
exception cases, this is perfectly fine.  Unfortunately,
g_io_channel_read_line(), in wrapping this internal function, always
promotes the length parameter, even in the case of error.

Stop doing that in order to avoid overwriting the callers's variable
with junk in the error case.

https://bugzilla.gnome.org/show_bug.cgi?id=731339
2014-06-28 13:51:23 -04:00
Bastien Nocera
88b284c070 GDateTime: Add guards to g_date_time_new()
https://bugzilla.gnome.org/show_bug.cgi?id=728401
2014-06-28 13:46:17 -04:00
Florian Pelz
f18811f2dc docs: Fix formatting of g_alloca documentation.
https://bugzilla.gnome.org/show_bug.cgi?id=729825
2014-06-28 13:43:23 -04:00
Daniel Macks
cc38cb359f Convert multiple #if/#endif to single #if/#elif/#endif
https://bugzilla.gnome.org/show_bug.cgi?id=731424
2014-06-28 13:19:56 -04:00
Patrick Welche
ab9f63fadd gmessages: make g_assert_warning compiler friendly
https://bugzilla.gnome.org/show_bug.cgi?id=720708
2014-06-28 13:17:16 -04:00
Ryan Lortie
dce88768dc all: remove use of 'register' keyword
We should have done this a decade ago...

https://bugzilla.gnome.org/show_bug.cgi?id=730293
2014-06-28 13:07:52 -04:00
Christian Persch
d217429729 unicode: Update to unicode 7.0.0
See bug https://bugzilla.gnome.org/show_bug.cgi?id=731929.
2014-06-28 12:49:38 -04:00
Christian Persch
30ed5f53e2 unicode: Switch compose_second_single to gunichar
This will be required for the update to unicode 7.0.0.
2014-06-28 12:49:07 -04:00
Christian Persch
7e3d32b705 unicode: Move gscripttable.h generation into main script
So we just have to run one script when updating the unicode data, not two.
2014-06-28 12:49:07 -04:00
Christian Persch
33c8a89490 unicode: Simplify width table generation
Move width table generation into the gen-unicode-tables.pl script. This makes
updating the tables automatic without the previously required manual editing
required to insert the tables in the right place of the source code.
2014-06-28 12:49:07 -04:00
Ryan Lortie
4d327bdcb0 GTimeZone: remove some dead code
Remove code that parsed out and stored the unused isstd and isgmt
fields.
2014-06-27 13:21:15 -04:00
Ryan Lortie
f727c820b8 gvariant tests: workaround libc/compiler "issue"
memcmp() is declared by glibc as follows:

  /* Compare N bytes of S1 and S2.  */
  extern int memcmp (const void *__s1, const void *__s2, size_t __n)
       __THROW __attribute_pure__ __nonnull ((1, 2));

despite the fact that it is valid to call it with a null pointer if the
size is zero.

gcc 4.9.0 contains a new optimisation that sees that we pass a pointer
to this function and concludes that it certainly must not be null,
removing a later check and thereby causing a crash.

We protect the invocation of memcmp() with a condition to prevent gcc
from making this false assumption (arguably under wrong advice from
glibc).
2014-06-24 14:18:29 -04:00
Philip Withnall
afea86a7ef goption: Remove an unused assignment
Coverity issue: #1159514

https://bugzilla.gnome.org/show_bug.cgi?id=732005
2014-06-22 12:57:57 +01:00
Philip Withnall
6b8ae8f21b gwakeup: Clarify buffer sizing in g_wakeup_signal()
The code in g_wakeup_signal() is currently correct: it writes a 64-bit
counter increment value if the FD is an eventfd, and writes an arbitrary
8-bit value if using a normal pipe.

However, the reasoning behind these buffer sizes is not clear, and the
mismatch between the allocated buffer size and the length passed to
write() in the pipe case could be mistaken for a bug.

Coverity issue: #1159490

https://bugzilla.gnome.org/show_bug.cgi?id=732002
2014-06-21 17:41:31 +01:00
Ryan Lortie
bef557e55d gatomic: disable GCC extension atomics for clang
clang defines the macro that we use to test for GCC's extension support
for C11 atomics, but doesn't define the extension in the same way.
Check for clang and disable the macros again if we find it.

https://bugzilla.gnome.org/show_bug.cgi?id=731513
2014-06-20 16:00:48 -04:00
Colin Walters
f7d7e5ab2f gbookmarkfile: Cleaner error handling code to pacify static analysis
A static analyzer flagged the g_file_get_contents() call as not
checking its return value.  While the code here is actually correct,
it's verbose at best.

I think the "goto out + cleanup" code style is substantially cleaner,
less error prone, and easier to read.  It also will pacify the static
analyzer.

https://bugzilla.gnome.org/show_bug.cgi?id=731584
2014-06-12 13:25:06 -04:00
Tim-Philipp Müller
256305dea5 gthread: use inline keyword for _get_impl() functions
Give compiler a hint that these should be inlined,
which doesn't seem to happen by default with -O2.
Yields 5% speedup in artificial benchmarks, and
1% speedup in a real-world test case doing a lot
of mutex locking and unlocking.

https://bugzilla.gnome.org/show_bug.cgi?id=730807
2014-06-06 11:41:12 -04:00
Ryan Lortie
db0e43d25a gatomic: use GCC C11-style atomics, if available
GCC does not yet support ISO C11 atomic operations, but it has
compatible versions available as an extension.  Use these for load and
store if they are available in order to avoid emitting a hard fence
instruction (since in many cases, we do not need it -- on x86, for
example).

For now we use the fully seqentially-consistent memory model, since
these APIs are documented rather explicitly: "This call acts as a full
compiler and hardware memory barrier".

In the future we can consider introducing new APIs for the more relaxed
memory models, if they are available (or fall back to stricter ones
otherwise).

https://bugzilla.gnome.org/show_bug.cgi?id=730807
2014-06-06 11:41:12 -04:00
Ryan Lortie
875eeb2ca1 gatomic: whitespace fixes
https://bugzilla.gnome.org/show_bug.cgi?id=730807
2014-06-06 11:41:12 -04:00
Ryan Lortie
aa0e8735c1 gatomic: fix typo in deprecation attribute
https://bugzilla.gnome.org/show_bug.cgi?id=730807
2014-06-06 11:41:12 -04:00
David King
c4fc3aa525 valgrind.h: Update to latest upstream version
Avoid crashes in g_type_free_instance() on mingw64.

https://bugzilla.gnome.org/show_bug.cgi?id=730198
2014-06-04 12:49:28 +01:00
Matthias Clasen
90671cd3cd docs: Add missing language annotations 2014-06-01 09:38:49 -04:00
Emmanuele Bassi
a0c3fdfae0 docs: Replace <structname> tags with back ticks
https://bugzilla.gnome.org/show_bug.cgi?id=731050
2014-05-31 19:22:15 +01:00
Matthias Clasen
ab18d71e6f Minor documentation additions and corrections
Going for 100%.
2014-05-31 10:54:02 -04:00
Matthias Clasen
f38b438c96 docs: Fill in the gspawn long description 2014-05-31 10:54:02 -04:00
Matthias Clasen
06b7786f31 docs: Fill in gshell long description 2014-05-31 10:54:02 -04:00
Thiago Santos
79f930f6dc gconvert: mention that the g_convert len should be in bytes
Some charsets have each char with more than one byte, make it clear that
the length should be in bytes

https://bugzilla.gnome.org/show_bug.cgi?id=730963
2014-05-30 13:51:16 +02:00
Philip Withnall
d3fd88ddd5 gtestutils: Error out if /dev/null stdin redirection fails
https://bugzilla.gnome.org/show_bug.cgi?id=730189
2014-05-26 08:39:40 +01:00
Matthias Clasen
ace7658b28 Trivial: fix a guard comment
The conventional comment for the #endif at the bottom of the
header was not matching the #ifdef at the top in glib-private.h.
Fix that.
2014-05-21 07:41:08 -04:00
Philip Withnall
03a82ce898 gthread: Fix use of a local variable after it went out of scope
This could theoretically cause problems, although in practice we would
have seen them by now (the bug was introduced in 2012).

Coverity issue: #1159486

https://bugzilla.gnome.org/show_bug.cgi?id=730277
2014-05-20 11:01:38 +01:00
Philip Withnall
46b7217fbf gtestutils: Don’t free unassigned variables in an error path
If the stream is invalid, msg.nums and msg.strings have not been
assigned to, so don’t free them.

Coverity issue: #1159505
2014-05-15 14:35:19 +01:00
Sébastien Wilmet
430e6fd6ad doc: various improvements
- GSubprocessLauncher exists since 2.40, not 2.36
- more logical order for g_markup functions
- fix short description of GMarkup
- GMarkupParser: specify that some parameters are NULL-terminated.
- g_string_new (NULL); is possible.
- other trivial fixes.

https://bugzilla.gnome.org/show_bug.cgi?id=728983
2014-05-09 18:47:42 +02:00
Matthias Clasen
49f5737f00 Add a testcase for the previous fix
This testcase tests that short option arguments are
not erroneously added to the remaining argument array
when g_option_context_set_ignore_unknown_options is
called.
https://bugzilla.gnome.org/show_bug.cgi?id=729563
2014-05-05 20:30:35 -04:00
Kjell Ahlstedt
85606f6093 goption: Don't include parsed option values in G_OPTION_REMAINING
After a call to g_option_context_set_ignore_unknown_options(context, TRUE),
the values of short options were included in the array returned by a
G_OPTION_REMAINING option.

https://bugzilla.gnome.org/show_bug.cgi?id=729563
2014-05-05 20:29:29 -04:00