Commit Graph

56 Commits

Author SHA1 Message Date
Michael Catanzaro
18a0d95aa2 Fix -Wsign-compare warning
[23/236] Compiling C object 'lib/76b5a...isc@sha/contrib_gvdb_gvdb-reader.c.o'.
../../../../Projects/epiphany/lib/contrib/gvdb/gvdb-reader.c: In function ‘gvdb_table_get_names’:
../../../../Projects/epiphany/lib/contrib/gvdb/gvdb-reader.c:428:27: warning: comparison of integer expressions of different signedness: ‘guint32’ {aka ‘unsigned int’} and ‘gint’ {aka ‘int’} [-Wsign-compare]
  428 |           else if (parent < n_names && names[parent] != NULL)
      |                           ^

To fix this, we have to change n_names to guint, and then also change
the types of everything it's compared against. This seems to be safe
since none of these should ever be negative.
2019-06-22 13:36:45 -05:00
Philip Withnall
a6f0eadb51 Merge branch 'mcatanzaro/write-contents-async' into 'master'
Add gvdb_table_write_contents_async()

See merge request GNOME/gvdb!4
2019-06-21 17:08:24 +00:00
Michael Catanzaro
5b455175b4 Remove trailing whitespace 2019-06-21 10:11:08 -05:00
Michael Catanzaro
16fb81cd7e Add some g_return checks to gvdb_table_write_contents()
I'm not auditing all the public functions in this file for precondition
checks, but since I'm adding an async version of this function, it
makes sense to ensure there are matching checks for the sync version.
2019-06-21 10:04:49 -05:00
Michael Catanzaro
d12c5aaba8 Add gvdb_table_write_contents_async()
This is just an async version of gvdb_table_write_contents().

Future work: someone could write an async version of gvdb_table_new(),
then sync I/O would no longer be required to construct a GvdbTable.
2019-06-21 10:04:49 -05:00
Philip Withnall
93ebac014a Merge branch 'mcatanzaro/license' into 'master'
Add COPYING file to indicate the license

See merge request GNOME/gvdb!5
2019-06-21 10:10:14 +00:00
Michael Catanzaro
05b0bb5fa5 Add COPYING file to indicate the license 2019-06-20 23:23:20 +00:00
Philip Withnall
25942f0176 Merge branch 'array-size' into 'master'
Fix size of preallocated array

See merge request GNOME/gvdb!3
2019-02-25 12:39:06 +00:00
Philip Withnall
7bf49c8df7 Fix size of preallocated array
Commit 084e1d868 added a preallocation to an array to avoid
reallocations later on, but neglected the fact that after N insertions
into the array, there’s always a NULL terminator added to the end. Fix
the preallocation to include that NULL terminator.

This doesn’t change the correctness of the code, but should eliminate
one reallocation.

Spotted by Sebastian Dröge. See
https://gitlab.gnome.org/GNOME/glib/merge_requests/674.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2019-02-25 12:38:08 +00:00
Michael Catanzaro
1fb31a16c3 Merge branch 'wip/lantw/use-weak-symbols-in-gvdb' into 'master'
build: Use weak bindings in gvdb to fix linking with LLD

Closes dconf#47

See merge request GNOME/gvdb!2
2018-11-21 16:48:01 +00:00
Ting-Wei Lan
e1bcd7529e build: Use weak bindings in gvdb to fix linking with LLD
Since tests/dconf-mock-gvdb.c has functions conflicting with the real
gvdb and it is intended for the former to override the latter in tests,
we have to make functions in gvdb library have weak bindings instead of
the default strong bindings to avoid duplicate symbol errors.

Fixes https://gitlab.gnome.org/GNOME/dconf/issues/47
2018-11-22 00:38:09 +08:00
Georges Basile Stavracas Neto
2d462bf661 Merge branch '1454-follow-ups' into 'master'
Minor API fixes

See merge request GNOME/gvdb!1
2018-08-16 15:13:18 +00:00
Philip Withnall
084e1d8680 Preallocate a GPtrArray to avoid some reallocations later on
Suggested by Georges Basile Stavracas Neto.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-16 15:44:09 +01:00
Philip Withnall
a44329c244 Fix type of length returned by gvdb_table_get_names()
It should not be unsigned. The type in the on-disk format is gint32, so
we need to return something at least as wide as that. However, we
should not expose the implementation detail that the on-disk format is
specifically gint32. Use a gsize, since that’s the normal type for array
lengths — but check that we’re not on a platform where (somehow) gsize
is smaller than gint32.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-16 15:36:32 +01:00
Philip Withnall
7bed7ea77d Add missing introspection annotations to gvdb_table_get_names()
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-16 15:36:10 +01:00
Philip Withnall
57962aac85 docs: Clarify error values for empty files when loading
Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 14:34:19 +01:00
Philip Withnall
d2f0461ec0 docs: Use ‘Returns:’ instead of the invalid ‘@returns’
This is based on the commit 59a24ab5a3 in GLib.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 14:34:19 +01:00
Philip Withnall
c78664e101 Update FSF’s address
(This is based on commit 892fc2e4 from dconf.)

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 14:34:19 +01:00
Sébastien Wilmet
4763db8a4c gio/gvdb/: LGPLv2+ -> LGPLv2.1+
https://bugzilla.gnome.org/show_bug.cgi?id=776504
2018-08-13 14:34:19 +01:00
Philip Withnall
7fd9f61dbd Avoid calling Standard C string/array functions with NULL arguments
glibc string.h declares memcpy() with attribute(nonnull(1,2)), causing
calls with NULL arguments to be treated as undefined behaviour.
This is consistent with ISO C99 and C11, which state that passing 0
to string functions as an array length does not remove the requirement
that the pointer to the array is a valid pointer.
gcc -fsanitize=undefined catches this while running OSTree's test suite.

Similarly, running the GLib test suite reports similar issues for
qsort(), memmove(), memcmp().

(This is a partial cherry-pick of commit e5ed410c8c from GLib.)

Signed-off-by: Simon McVittie <smcv@debian.org>
Bug: https://bugzilla.gnome.org/show_bug.cgi?id=775510
Reviewed-by: Colin Walters
2018-08-13 14:34:19 +01:00
Philip Withnall
355228121e doap: Update maintainers list to synchronise with GLib
GVDB is essentially part of GLib, so should have the same maintainer
list.

At least this way, it’s not just maintained by one absentee maintainer.

Signed-off-by: Philip Withnall <withnall@endlessm.com>
2018-08-13 14:29:51 +01:00
Ryan Lortie
2600082151 reader: embrace GBytes
Drop gvdb_table_new_from_data() and add gvdb_table_new_from_bytes().

Since the underlying backingstore of a GvdbTable is now always
refcounted, drop the refcounting on GvdbTable itself.
2012-11-09 13:19:13 -05:00
Ryan Lortie
fc37611a97 gvdb-reader: drop gvdb_table_walk()
The attempt at the simple method for preventing unbounded recursion
proved to be insufficient due to the existence of dconf databases in the
wild that violated the rule (leading to the entire content of the
database being scrapped).  It also still had the ugly assert for less
than 64 levels of recursion that could have been hit by a determined
advisary.

gvdb_table_get_names() allows the dconf-service to do everything it
needs without the troubles associated with the walk approach.
2012-07-09 15:28:17 -04:00
Ryan Lortie
d9577f100b gvdb-reader.c: add gvdb_table_get_names()
This function lists off all names that appear within a particular hash.
2012-07-09 14:32:22 -04:00
Ryan Lortie
82cbc59297 remove a stray variable
This was used to implement a much more complicated check which was
dismissed in favour of the simple 'must follow in file' approach.
2012-07-08 10:44:05 -04:00
Ryan Lortie
374cb1bc87 gvdb-reader: robustness improvements
Improve the robustness of gvdb-reader in two ways.

First: ensure that the result of gvdb_table_has_value() always agrees
with gvdb_table_get_value().  Those two could disagree in the case that
the value was recorded as existing but pointed to an out-of-bounds
region.

Second: prevent gvdb_table_walk() from getting stuck in finite loops due
to self-referential directories.
2012-07-06 21:42:04 -04:00
Ryan Lortie
a9551ccf92 more whitespace fixes 2012-07-05 23:14:55 -04:00
Ryan Lortie
ae3d42c60f gvdb-reader: refuse to open file with small header
Clean up the logic for dealing with invalid headers and include the case
where the file is too small to contain a fully-formed header.
2012-07-05 19:24:46 -04:00
Ryan Lortie
4e77b52ad8 gvdb-reader: correct whitespace damage 2012-07-05 19:13:58 -04:00
Colin Walters
7683c2b796 builder: Note don't actually implement bloom filters 2012-03-08 11:30:03 -05:00
Alexander Larsson
73acf01618 Support creating a GvdbReader from data
This is needed for the glib resource work.
2012-01-13 15:59:56 +01:00
Murray Cumming
d1f6300363 Docs: Changed can not to cannot.
This is a backport from the glib commit 30fdc1a799
2012-01-13 09:23:06 +01:00
Ryan Lortie
92652ac791 hashing: always use signed chars
Our hashing of non-ASCII strings was undefined due to the fact that
'char' is signed on some platforms, unsigned on others.  Always use a
signed char.

Discovered by Alexander Larsson.

https://bugzilla.gnome.org/show_bug.cgi?id=658806
2011-09-12 08:12:44 -04:00
Ryan Lortie
a5dd6fcc4f builder: do not include <unistd.h> on win32
Spotted by Kean Johnston <kean.johnston@gmail.com>.

https://mail.gnome.org/archives/gtk-devel-list/2011-April/msg00010.html
2011-04-15 09:27:38 -04:00
Ryan Lortie
3812559659 Remove unused variable in gvdb-reader
As originally committed against dconf by Owen.

Newer GCC flags this.
2011-02-03 17:26:51 -05:00
Ryan Lortie
03b6b9fb97 Mark a symbol as G_GNUC_INTERNAL 2011-01-25 18:26:21 -05:00
Ryan Lortie
a2918d6c3e Fix some harmless sign compare warnings 2011-01-17 15:19:14 -05:00
Ryan Lortie
ba5619ba7f C++ify the reader header 2011-01-17 15:15:46 -05:00
Ryan Lortie
92c22e7ca7 Fix some leaks in the GVDB builder 2010-12-15 11:36:14 -05:00
Ryan Lortie
814c0fcaaf Pass name_length to walk close function
For efficiency and safety.  This way we don't need to scan backwards for
the path separator (trusting that we will find it properly).
2010-12-07 01:36:09 -05:00
Ryan Lortie
e5e491c969 Add gvdb_table_get_raw_value() API for GSettings 2010-10-03 23:02:45 -04:00
Ryan Lortie
a35852bda3 Fix reader on big endian
Some of the hashtable code was failing to byteswap properly.
2010-10-03 21:10:35 -04:00
Ryan Lortie
d63f199d92 Fix is_valid() API
Actually dereference the pointer instead of just checking for NULL
2010-07-18 21:43:18 -04:00
Ryan Lortie
df40747190 Add gvdb_table_is_valid() API
Checks that the on-disk file is still valid.
2010-07-18 20:45:37 -04:00
Ryan Lortie
afea703422 Implement byteswapping in the reader 2010-06-10 15:27:46 -04:00
Ryan Lortie
9a8cba9eb5 drop "options" support 2010-06-10 13:34:56 -04:00
Ryan Lortie
5215d4b6d3 Add API for dconf's sake. 2010-04-28 12:39:02 -05:00
Ryan Lortie
daa1a73c75 Add a missing 'static' on internal functions 2010-04-22 15:45:47 -04:00
Ryan Lortie
291a5c9ed9 __value -> value to avoid stomping the C compiler 2010-04-20 20:12:41 -04:00
Ryan Lortie
2d9811ebda Don't write out zero-byte sections in builder
This and the previous issue caught by Christian Persch in bug #616156
2010-04-19 10:28:44 -04:00