Commit Graph

24 Commits

Author SHA1 Message Date
Roman Gilg 2ff6eaad85 Correct xorg_list_is_empty return value description
The helper xorg_list_is_empty returns True when the list is empty and not when
it contains one or more elements.

Signed-off-by: Roman Gilg <subdiff@gmail.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2018-02-12 08:09:53 +10:00
Thomas Klausner 63f83d1b7f Fix uninitialized variable warnings reported by clang
v2: Move initializing pos into the first clause of the for statement. We
have to keep this macro equivalent to a plain for statement from the
user's perspective, otherwise callers need to {} things to keep control
flow correct. [ajax]

Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-06 09:42:59 -05:00
Adam Jackson 792176417f Revert "Fix uninitialized variable warnings reported by clang"
Crashes at startup:

dmt:~/git/xserver% ./hw/kdrive/ephyr/Xephyr :1
(EE) Backtrace:
(EE) 0: ./hw/kdrive/ephyr/Xephyr (OsSigHandler+0x29) [0x47c8f9]
(EE) 1: /lib64/libc.so.6 (__restore_rt+0x0) [0x7f38d4de6b1f]
(EE) 2: ./hw/kdrive/ephyr/Xephyr (InitNotifyFds+0x17) [0x478697]
(EE) 3: ./hw/kdrive/ephyr/Xephyr (OsInit+0x1e) [0x47c99e]
(EE) 4: ./hw/kdrive/ephyr/Xephyr (dix_main+0x11c) [0x446efc]
(EE) 5: /lib64/libc.so.6 (__libc_start_main+0xf0) [0x7f38d4dd2580]
(EE) 6: ./hw/kdrive/ephyr/Xephyr (_start+0x29) [0x427099]
(EE) 7: ? (?+0x29) [0x29]
(EE)
(EE) Segmentation fault at address 0x0

This reverts commit a221d4737c.
2016-01-05 12:03:54 -05:00
Thomas Klausner a221d4737c Fix uninitialized variable warnings reported by clang
Signed-off-by: Thomas Klausner <wiz@NetBSD.org>
Acked-by: Michel Dänzer <michel.daenzer@amd.com>
2016-01-05 11:18:48 -05:00
Peter Hutterer 3ccec1b5ba include: fix documentation for list.h
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2014-11-12 10:24:55 +10:00
Adam Jackson 13b507409f list: Avoid using X types
In particular, Bool.  This is not an ABI break:

/usr/include/X11/Xdefs.h:typedef int Bool;

Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Adam Jackson <ajax@redhat.com>
2013-09-10 13:28:24 -04:00
Robert Morell 7050aae69c list.h: Make xorg_list_init inline
Otherwise this file is emitted in every unit that includes it.

Signed-off-by: Robert Morell <rmorell@nvidia.com>
Reviewed-by: Jamey Sharp <jamey@minilop.net>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-03-13 10:44:19 +10:00
Peter Hutterer 1cb19803f0 include: fix typo in list description
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
2013-02-08 13:47:24 +10:00
Jeremy Huddleston Sequoia b8ab93dfbc list: Use offsetof() and typeof() to determine member offsets within a structure
Some compilers have difficulty with the previous implementation which
relies on undefined behavior according to the C standard.  Using
offsetof() from <stddef.h> (which most likely just uses
__builtin_offsetof on modern compilers) allows us to accomplish this
without ambiguity.

This fix also requires support for typeof().  If your compiler does not
support typeof(), then the old implementation will be used.  If you see
failures in test/list, please try a more modern compiler.

v2: Added fallback if typeof() is not present.

Signed-off-by: Jeremy Huddleston Sequoia <jeremyhu@apple.com>
Reviewed-by: Peter Hutterer <peter.hutterer@who-t.net>
2012-08-29 16:09:20 -07:00
Peter Hutterer 167993254a list.h: don't crash when removing an element from a NULL list
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Signed-off-by: Keith Packard <keithp@keithp.com>
2012-07-05 10:09:18 -07:00
Keith Packard 9838b7032e Introduce a consistent coding style
This is strictly the application of the script 'x-indent-all.sh'
from util/modular. Compared to the patch that Daniel posted in
January, I've added a few indent flags:

	-bap
	-psl
	-T PrivatePtr
	-T pmWait
	-T _XFUNCPROTOBEGIN
	-T _XFUNCPROTOEND
	-T _X_EXPORT

The typedefs were needed to make the output of sdksyms.sh match the
previous output, otherwise, the code is formatted badly enough that
sdksyms.sh generates incorrect output.

The generated code was compared with the previous version and found to
be essentially identical -- "assert" line numbers and BUILD_TIME were
the only differences found.

The comparison was done with this script:

dir1=$1
dir2=$2

for dir in $dir1 $dir2; do
	(cd $dir && find . -name '*.o' | while read file; do
		dir=`dirname $file`
		base=`basename $file .o`
		dump=$dir/$base.dump
		objdump -d $file > $dump
	done)
done

find $dir1 -name '*.dump' | while read dump; do
	otherdump=`echo $dump | sed "s;$dir1;$dir2;"`
	diff -u $dump $otherdump
done

Signed-off-by: Keith Packard <keithp@keithp.com>
Acked-by: Daniel Stone <daniel@fooishbar.org>
Acked-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2012-03-21 13:54:42 -07:00
Alan Coopersmith ca64912c02 Namespace list api to reduce conflicts with similar system headers
Rename functions/macros from list_* to xorg_list_*
Rename struct from struct list to struct xorg_list.

Signed-off-by: Alan Coopersmith <alan.coopersmith@oracle.com>
Reviewed-by: Keith Packard <keithp@keithp.com>
In-sed-I-trust: Peter Hutterer <peter.hutterer@who-t.net>
2012-02-03 14:23:24 -08:00
Peter Hutterer fac464e310 include: rename "foos" to "list_of_foos" in the struct list documentation
Makes things a little easier to read.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:15 +10:00
Peter Hutterer 7dfe8c32a9 include: update struct list documentation to use one set of structs only
The example at the top of the file used a struct bar and a list of struct
foos. Use those two throughout instead of a different struct foo for the
examples and for the API documentation.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:15 +10:00
Peter Hutterer 18539c89ec include: a new list element does not need initialization, state so
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:15 +10:00
Peter Hutterer 58dc73314b include: point to the tests in list.c as examples
Even with the documentation, the list.c tests are the best examples.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:15 +10:00
Peter Hutterer c8e451a8e7 include: add list_last_entry to get the tail of a list
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:14 +10:00
Peter Hutterer 6acebf9e12 include: add list_append()
The existing list_add() prepends to the list, but in some cases we need the
list ordered in the way we append the elements.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Chase Douglas <chase.douglas@canonical.com>
2011-12-06 18:15:14 +10:00
Peter Hutterer c39c8d3428 input: switch InputOption to use XF86OptionRec storage.
Use the same struct for both InputOption and XF86OptionRec so we don't need
to convert to and fro the two in the config backends.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Dan Nicholson <dbn.lists@gmail.com>
Reviewed-by: Daniel Stone <daniel@fooishbar.org>
2011-10-25 14:06:39 +10:00
Peter Hutterer fcafe82575 Add null-terminated list interface.
This is a set of macros to provide a struct list-alike interface for classic
linked lists such as the XF86OptionRec or the DeviceIntRec. The typical
format for these is to have a "struct foo *next" pointer in each struct foo
and walk through those. These macros provide a few basic functions to add to,
remove from and iterate through these lists.

While struct list is in some ways more flexible, switching legacy code to
use struct list is not alway viable. These macros at least reduce the amount
of open-coded lists.

Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-08-22 15:56:53 +10:00
Peter Hutterer 816f1f8ffa include: document list interface.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Reviewed-by: Alan Coopersmith <alan.coopersmith@oracle.com>
2011-02-25 09:03:08 +10:00
Kristian Høgsberg 2c0159d217 list.h: Fix list_for_each_entry_safe()
Can't use next as a macro argument since we're accessing the .next field
of struct list.

Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Keith Packard <keithp@keithp.com>
Signed-off-by: Keith Packard <keithp@keithp.com>
2010-06-22 12:21:51 -07:00
Kristian Høgsberg 32381363cd list.h: Add list_for_each_entry_safe()
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Adam Jackson <ajax@redhat.com>
2010-05-11 11:01:35 -04:00
Francisco Jerez e38e01081a Import linked list helpers from the intel DDX.
Borrowed from i830.h, except for list_for_each_entry().

Signed-off-by: Francisco Jerez <currojerez@riseup.net>
Signed-off-by: Kristian Høgsberg <krh@bitplanet.net>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
2010-03-16 09:51:08 -04:00