Commit Graph

26 Commits

Author SHA1 Message Date
Philip Withnall
9b4c50f63d all: Remove trailing newlines from g_message()/g_warning()/g_error()s
All those logging functions already add a newline to any message they
print, so there’s no need to add a trailing newline in the message
passed to them.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
Reviewed-by: nobody
2018-04-27 16:46:19 +01:00
Philip Withnall
5cddde1fb2 Consistently save errno immediately after the operation setting it
Prevent the situation where errno is set by function A, then function B
is called (which is typically _(), but could be anything else) and it
overwrites errno, then errno is checked by the caller.

errno is a horrific API, and we need to be careful to save its value as
soon as a function call (which might set it) returns. i.e. Follow the
pattern:
  int errsv, ret;
  ret = some_call_which_might_set_errno ();
  errsv = errno;

  if (ret < 0)
    puts (strerror (errsv));

This patch implements that pattern throughout GLib. There might be a few
places in the test code which still use errno directly. They should be
ported as necessary. It doesn’t modify all the call sites like this:
  if (some_call_which_might_set_errno () && errno == ESOMETHING)
since the refactoring involved is probably more harmful than beneficial
there. It does, however, refactor other call sites regardless of whether
they were originally buggy.

https://bugzilla.gnome.org/show_bug.cgi?id=785577
2017-08-03 10:21:13 +01:00
Stef Walter
3e041ce5ad mainloop-test: Fix uninitialized memory access in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711751
2013-11-11 17:35:26 +01:00
Stef Walter
ae1764b4e0 mainloop-test: Fix leaks in tests
https://bugzilla.gnome.org/show_bug.cgi?id=711751
2013-11-10 22:43:25 +01:00
Ryan Lortie
210b1f8b42 Remove a bunch of lingering g_thread_init()
After this patch, there is but one remaining use of g_thread_init(),
which is in tests/slice-threadinit.c, a testcase dedicated to testing
the functionality of gslice across a g_thread_init() boundary.

This testcase is pretty meaningless these days... probably we should
delete it.
2013-05-31 23:03:19 -04:00
Simon McVittie
837db1a026 Fix more warning-addition fallout
I'm normally a big fan of small atomic commits, but I also want to get
things done this afternoon...

Bug: https://bugzilla.gnome.org/show_bug.cgi?id=687441
Reviewed-by: Colin Walters <walters@verbum.org>
2012-11-02 16:27:19 +00:00
Ryan Lortie
6f343ca548 Remove g_mutex_new()/g_cond_new() in testcases
These were the last users of the dynamic allocation API.

Keep the uses in glib/tests/mutex.c since this is actually meant to test
the API (which has to continue working, even if it is deprecated).

https://bugzilla.gnome.org/show_bug.cgi?id=660739
2011-10-04 19:35:27 -04:00
Dan Winship
5bc7729d16 Make threads mandatory
G_THREADS_ENABLED still exists, but is always defined. It is still
possible to use libglib without threads, but gobject (and everything
above it) is now guaranteed to be using threads (as, in fact, it was
before, since it was accidentally impossible to compile with
--disable-threads).

https://bugzilla.gnome.org/show_bug.cgi?id=616754
2011-09-09 12:41:55 -04:00
Colin Walters
183102104a [mainloop-test] Fix compilation errors 2010-05-26 16:21:15 -04:00
Havoc Pennington
6b53e4826f GSource: add g_source_set_name, g_source_get_name, g_source_set_name_by_id
These allow applications to give meaningful names to their sources.
Source names can then be used for debugging and profiling, for
example with systemtap or gdb.

https://bugzilla.gnome.org/show_bug.cgi?id=606044
2010-05-25 16:59:22 -04:00
Tor Lillqvist
7d2ec70a49 Not needed, just use -DPCRE_STATIC.
2007-11-07  Tor Lillqvist  <tml@novell.com>

	* glib/update-pcre/notdll.patch: Not needed, just use -DPCRE_STATIC.

	* glib/update-pcre/Makefile.am: Drop notdll.patch.

	* glib/update-pcre/Makefile.am-1
	* glib/update-pcre/update.sh
	* glib/pcre/Makefile.am
	* glib/Makefile.am: Use -DPCRE_STATIC.

	* tests/gio-test.c
	* tests/mainloop-test.c
	* tests/spawn-test.c: #define pipe(fds) _pipe(fds, 4096,
	_O_BINARY) on Windows.

	* tests/regex-test.c (test_expand): Don't print NULL with %s.


svn path=/trunk/; revision=5805
2007-11-07 09:49:25 +00:00
Matthias Clasen
7221f500f5 Make the tests silent on success.
2005-07-14  Matthias Clasen  <mclasen@redhat.com>

	* tests/spawn-test.c:
	* tests/uri-test.c:
	* tests/thread-test.c:
	* tests/queue-test.c:
	* tests/mainloop-test.c:
	* tests/iochannel-test.c:
	* tests/gio-test.c:
	* tests/child-test.c: Make the tests silent on success.
2005-07-14 05:20:14 +00:00
Manish Singh
d1f37d5053 add -DG_DISABLED_DEPRECATED
Tue Oct 15 15:07:45 2002  Manish Singh  <yosh@gimp.org>

        * gmodule/Makefile.am gobject/Makefile.am gthread/Makefile.am:
        add -DG_DISABLED_DEPRECATED

        * tests/gio-test.c tests/mainloop-test.c tests/string-test.c
        tests/testglib.c test/tree-test.c tests/unicode-collate.c
        tests/unicode-normalize.c: Deprecation cleanup
2002-10-15 22:16:57 +00:00
Owen Taylor
27dc698317 Fix a minor memory leak.
Mon Oct 14 15:32:14 2002  Owen Taylor  <otaylor@redhat.com>

        * tests/mainloop-test.c (adder_response): Fix a minor memory
        leak.
2002-10-14 19:33:37 +00:00
Manish Singh
f92ba4ece8 use gsize instead of int where appropriate (64-bit cleanliness fix)
Sun Sep 29 12:15:44 2002  Manish Singh  <yosh@gimp.org>

        * tests/mainloop-test.c: use gsize instead of int where appropriate
        (64-bit cleanliness fix)
2002-09-29 19:16:31 +00:00
Sebastian Wilhelmi
d81ac5339f Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN throughout the
2002-07-04  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* tests/*.c: Added #undef G_DISABLE_ASSERT and #undef G_LOG_DOMAIN
	throughout the files, which didn't already have them. (#87312)
2002-07-04 15:19:30 +00:00
Owen Taylor
3481763c97 Recurse with may_block = FALSE, so we don't get into the pathology where
Thu Nov  1 21:48:43 2001  Owen Taylor  <otaylor@redhat.com>

        * tests/mainloop-test.c (recurser_idle): Recurse
        with may_block = FALSE, so we don't get into
        the pathology where the recurser_idle recurses
        for 10 iterations, and the only thing that is
        running is the recurser idle, which adds
        another recursion for each of those 10 iterations
        and....

        * tests/mainloop-test.c (create_crawler): Fix race
        condition where a crawler source could be destroyed
        before it was added to the crawler array.

        * test/Makefile.am: Add mainloop-test back.
2001-11-02 02:56:08 +00:00
Hans Breuer
847d8e9212 make it compile again
2001-07-20  Hans Breuer  <hans@breuer.org>

	* glib/glib/giowin32.c : make it compile again

	* glib/glib.def : updated exports

	* glib/makefile.msc.in :
	* glib/makefile.mingw.in :
	* tests/makefile.msc.in : reflect glib move

	* tests/mainloop-test.c : #include <io.h> for _pipe()

	* tests/gio-test.c : casts for strict compiler settings

	* makefile.msc.in : new master makefile reflecting the glib
	move. The '.in' isn't really needed anymore, because there
	is no version number in it
2001-07-20 17:13:52 +00:00
Owen Taylor
8951f96c50 Make some changes to the way that GMainContext works:
Sat Jun 30 15:49:10 2001  Owen Taylor  <otaylor@redhat.com>

	* glib/gmain.[ch]: (Mostly patch from Sebastian Wilhemi)
	Make some changes to the way that GMainContext works:

	 - a GMainContext is no longer associated with a single
	   thread, but any thread can acquire ownership
	   of thread and iterate.

	 - There is a facility g_main_context_wait() for
	   non-owner-threads to wait either for ownership
	   or for a condition to be broadcast.

	 - For efficiency, GMainLoop just piggybacks of
	   of the loops mutex / condition instead of
	   having a separate mutex/condition for each
	   GMainLoop.

	* glib/gthread.[ch]: Remove hacks to store the thread's
	GMainContext in the GThread structures, since we
	no longer have the GMainContext <=> GThread correspondence.

        * glib/gmain.[ch]: Make g_main_context_wakeup() public
	so someone could completely duplicate GMainLoop
	with the public API.

	* tests/mainloop-test: Fix up to the new API. Decidedly
	doesn't work at the moment, but that may be the IO
	channel changes, or preexisting locking problems.
2001-06-30 19:56:47 +00:00
Sebastian Wilhelmi
227d18bc46 Renamed g_thread_create to g_thread_create_full and added macro
2001-05-18  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* gthread.c, gthread.h: Renamed g_thread_create to
	g_thread_create_full and added macro g_thread_create, which omits
	'stack_size', 'bound' and 'priority' parameters. Also removed
	'bound' from GThread struct.

	* gthreadpool.h, gthreadpool.c: Adapted GThreadPool to the above
	changes. GThreadPool lost the 'priority' and 'bound'
	members. g_thread_pool_new the 'stack_size', 'bound' and
	'priority' parameters.

	* tests/mainloop-test.c, tests/thread-test.c,
	tests/threadpool-test.c: Adapted to the above changes.
2001-05-18 08:44:57 +00:00
Sebastian Wilhelmi
cd00d6e2cc Moved func and arg members from GRealThread to GThread, such that they can
2001-05-08  Sebastian Wilhelmi  <wilhelmi@ira.uka.de>

	* gmain.c, gthread.c, gthread.h: Moved func and arg members from
	GRealThread to GThread, such that they can be accessed by the
	user.

	* gthread.c, gthread.h: Due to popular demand (Tim being the
	populus here ;-) threads now have a 'return value', which is
	returned by g_thread_join and is either the return of the topmost
	thread function or the value given to g_thread_exit.

	* gthreadpool.c, tests/mainloop-test.c, tests/thread-test.c:
	Adapted to the above change.
2001-05-08 08:23:18 +00:00
Owen Taylor
c530e1e1dd Define _GNU_SOURCE for stpcpy
Tue Apr 17 10:43:36 2001  Owen Taylor  <otaylor@redhat.com>

	* gstrfuncs.c: Define _GNU_SOURCE for stpcpy

	* tests/mainloop-test.c (main): Wait for all threads
	to start before beginning tests.
2001-04-17 14:48:11 +00:00
Tor Lillqvist
deb68e1592 Get len using strlen() if arg is negative in the Win32 code, too.
2001-01-06  Tor Lillqvist  <tml@iki.fi>

	* gconvert.c (g_locale_to_utf8, g_locale_from_utf8): Get len using
	strlen() if arg is negative in the Win32 code, too.

	* giowin32.c: Changes necessary to be able to run
	mainloop-test. We can't close the fd that our (internal) reader
	thread is sitting doing a blocking read() from. We must terminate
	the thread first. Keep track of thread handle, and close it when
	thread is dying. Start reader thread with the lower-level
	CreateThread() instead of _beginthreadex() from the C runtime, in
	order to be able to use TerminateThread(). Hopefuly this isn't
	harmful.

	* glib.def: Update.

	* tests/makefile.{mingw,msc}.in (TESTS): Add mainloop-test and
	unicode-encoding.

	* tests/mainloop-test.c: Portability: <unistd.h>, need <fcntl.h>
	on Win32.

	* tests/unicode-encoding.c (process): Add missing "line" argument
	to fail(). On Win32, convert UTF-16LE, as libiconv'c ivonf always
	converts to UTF-16BE if we ask for unspecific UTF-16.
	(main) Handle also '\r'.
2001-01-06 03:09:46 +00:00
Owen Taylor
956f00ed96 move $enable_debug down below checks for GCC to avoid setting CFLAGS
Fri Jan  5 11:25:42 2001  Owen Taylor  <otaylor@redhat.com>

	* configure.in (PACKAGE): move $enable_debug down below
	checks for GCC to avoid setting CFLAGS prematurely,
	change checks to avoid adding -g twice.

	* gutf8.c (g_ucs4_to_utf8): Support len < 0 to mean
	0 termination.

	* gutf8.c (g_utf8_to_ucs4): Terminate result with 0.

	* tests/mainloop-test.c (main): Fix uses of
	g_main_loop_destroy().

	* tests/unicode-encoding.c tests/Makefile.am tests/utf8.txt:
	Tests for unicode-conversion code.

	* gconvert.c (g_convert, g_convert_with_fallback): work around
	a couple of GNU libc bugs.

	* gconvert.[ch] (g_{locale,filename}_{to,from}_utf8): Standardize
	arguments to match g_convert(). Document.

	* gunicode.[ch]:
	  - Implement conversion functions to and from UTF-16
	  - Standardize unicode conversion functions on prototype like
	    g_convert.
	  - Add a lot of error checking to unicode conversion functions.

	* gunicode.[ch] (g_utf8_to_ucs4_fast): Add fast, non-checking
	variant of g_utf8_to_ucs4.

	* gutf8.c (g_utf8_validate):
	 - add g_return_if_fail (str != NULL).
	 - add checks for overlong strings, non-valid Unicode characters (>= 110000)
	   and single surrogates.
2001-01-05 21:22:47 +00:00
Owen Taylor
1084477e03 Add a bunch of unrefs.
Thu Dec  7 15:22:30 2000  Owen Taylor  <otaylor@redhat.com>

	* tests/mainloop-test.c (recurser_start): Add a bunch
	of unrefs.

	* gmain.c (g_source_attach): Reference the source
	when adding (pointed out by Elliot)
2000-12-07 20:29:58 +00:00
Owen Taylor
e2fd4e2bd0 Major change in API for creating sources to handle multiple main loops
Tue Dec  5 12:23:04 2000  Owen Taylor  <otaylor@redhat.com>

        * gmain.[hc]: Major change in API for creating sources
	to handle multiple main loops (GMainContext *).

	GSources are now exposed as GSource * and implemented
	with structure derivation.

	* giochannel.[ch]: Changed vtable for GIOChannel to correspond
	to the new mainloop API, add g_io_channel_create_watch().

	* gtypes.h: Move GTimeVal here.

	* gthread.h: Remove gmain.h include to avoid circularity.

        * giounix.c: Update for new GMain API.

	* giowin32.c: Update for new GMain API. (No check for
	proper compilation or working.)

	* timeloop.c timeloop-basic.c: A benchmarking program for
	the main loop comparing the main loop against a
	hand-written (timeloop-basic.c) variant.

	* tests/mainloop-test.c: New torture test of mainloop.

	* docs/Changes-2.0.txt: Started. Added text about
	changes to GMain.

	* gmain.c (g_main_add_poll_unlocked): Initial fd->revents
	to zero. (#8482, Benjamin Kahn)
2000-12-05 20:45:33 +00:00