summaryrefslogtreecommitdiff
path: root/src/libsystemd/sd-hwdb
Commit message (Collapse)AuthorAgeFilesLines
* sd-hwdb: use return value from ordered_hashmap_iterate()Zbigniew Jędrzejewski-Szmek2019-08-031-2/+1
| | | | Why not? Coverity CID#1402329.
* tree-wide: (void)ify a few unlink() and rmdir()Lennart Poettering2019-03-271-1/+1
| | | | | | Let's be helpful to static analyzers which care about whether we knowingly ignore return values. We do in these cases, since they are usually part of error paths.
* headers: remove unneeded includes from util.hZbigniew Jędrzejewski-Szmek2019-03-272-0/+3
| | | | | This means we need to include many more headers in various files that simply included util.h before, but it seems cleaner to do it this way.
* util: split out nulstr related stuff to nulstr-util.[ch]Lennart Poettering2019-03-141-1/+1
|
* util: split out sorting related calls to new sort-util.[ch]Lennart Poettering2019-03-131-0/+1
|
* sd-hwdb: fix off_t vs. size_t confusion in castZbigniew Jędrzejewski-Szmek2019-03-041-1/+1
| | | | > on 32bit, size_t is 32bit, but .st_size is off_t hence 64bit
* sd-hwdb: some minor logging and style updatesZbigniew Jędrzejewski-Szmek2019-03-041-12/+11
|
* sd-hwdb: use non-atomic reference countersZbigniew Jędrzejewski-Szmek2019-03-041-4/+3
| | | | | | The sd-hwdb objects cannot be used concurrently from two threads in any meaningful way, because query and iteration operations modify the object. Thus atomic reference counts are pointless.
* sd-hwdb: fix matching for characters with an ord > 127Peter Hutterer2019-02-131-1/+1
| | | | | | | | | | | Devices like the "Microsoft Microsoft® 2.4GHz Transceiver v9.0 Mouse" contain characters higher than 127. That ® is correctly stored in the hwdb and passed into the search field during query, but the comparison fails. Our search string is a const char *, trie_string() returns a const char * but the current character is cast to uint8_t. This causes anything over 127 to fail the match. Fix this, we're dealing with characters everywhere here after all.
* meson: define PROJECT_VERSION as the "bare" project versionZbigniew Jędrzejewski-Szmek2018-12-201-1/+1
| | | | | | | | | | | | | | Let's not use atoi() if we can simply provide the project version as a number. In C code, this is the numerical project version. In substitutions in other files, this is just the bare substitution. The "PACKAGE_" prefix is from autotools, and is strange. We call systemd a "project", and "package" is something that distros build. Let's rename. PACKAGE_URL is renamed to PROJECT_URL for the same reasons and for consistency. (This leave PACKAGE_VERSION as the stringified define for C code.)
* util-lib: split out all temporary file related calls into tmpfiles-util.cLennart Poettering2018-12-021-0/+1
| | | | | | | | This splits out a bunch of functions from fileio.c that have to do with temporary files. Simply to make the header files a bit shorter, and to group things more nicely. No code changes, just some rearranging of source files.
* Move LONG_LINE_MAX definition to fileio.hZbigniew Jędrzejewski-Szmek2018-11-141-1/+0
| | | | | | | | | | | All users of the macro (except for one, in serialize.c), use the macro in connection with read_line(), so they must include fileio.h. Let's not play libc games and require multiple header file to be included for the most common use of a function. The removal of def.h includes is not exact. I mostly went over the commits that switch over to use read_line() and add def.h at the same time and reverted the addition of def.h in those files.
* sd_hwdb: update log messagesYu Watanabe2018-10-241-6/+6
|
* hwdb: fgets() excorcismLennart Poettering2018-10-181-2/+9
|
* sd-hwdb: update error log a bitYu Watanabe2018-10-091-1/+1
|
* sd-hwdb: initialize variableYu Watanabe2018-09-201-1/+1
| | | | | | The variable 'fn' was not initialized on compat mode. Fixes CID#1395731.
* hwdb,udevadm: also unify hwdb_query() and hwdb_test()Yu Watanabe2018-09-192-0/+19
|
* sd-hwdb: use structured initializersYu Watanabe2018-09-191-18/+23
|
* hwdb: unify duplicated code and move it to hwdb-util.cYu Watanabe2018-09-192-0/+657
| | | | | | | | Both 'systemd-hwdb update' and 'udevadm hwdb --update' creates hwdb database. The database created by systemd-hwdb containes additional information such that priority, line number, and source filename. The unified function 'hwdb_update()' can take a flag 'compat' which controls the format version of created database.
* sd-hwdb: adjust included headersYu Watanabe2018-09-193-3/+5
|
* libsystemd: use DEFINE_ATOMIC_REF_UNREF_FUNC or frineds where applicableYu Watanabe2018-08-281-16/+8
|
* sd-hwdb: drop unused variableYu Watanabe2018-08-281-1/+0
|
* tree-wide: drop empty lines in commentsYu Watanabe2018-07-231-1/+0
|
* tree-wide: drop double newlineYu Watanabe2018-06-292-2/+0
|
* tree-wide: drop copyright headers from frequent contributorsZbigniew Jędrzejewski-Szmek2018-06-203-8/+0
| | | | | | | | Fixes #9320. for p in Shapovalov Chevalier Rozhkov Sievers Mack Herrmann Schmidt Rudenberg Sahani Landden Andersen Watanabe; do git grep -e 'Copyright.*'$p -l|xargs perl -i -0pe 's|/([*][*])?[*]\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\s*[*]([*][*])?/\n*|\n|gms; s|\s+([*#]\s+)?Copyright[^\n]*'$p'[^\n]*\n*|\n|gms' done
* tree-wide: beautify remaining copyright statementsLennart Poettering2018-06-143-5/+5
| | | | | | Let's unify an beautify our remaining copyright statements, with a unicode ©. This means our copyright statements are now always formatted the same way. Yay.
* tree-wide: drop 'This file is part of systemd' blurbLennart Poettering2018-06-143-6/+0
| | | | | | | | | | | | | | | | This part of the copyright blurb stems from the GPL use recommendations: https://www.gnu.org/licenses/gpl-howto.en.html The concept appears to originate in times where version control was per file, instead of per tree, and was a way to glue the files together. Ultimately, we nowadays don't live in that world anymore, and this information is entirely useless anyway, as people are very welcome to copy these files into any projects they like, and they shouldn't have to change bits that are part of our copyright header for that. hence, let's just get rid of this old cruft, and shorten our codebase a bit.
* tree-wide: drop license boilerplateZbigniew Jędrzejewski-Szmek2018-04-063-39/+0
| | | | | | | | | | Files which are installed as-is (any .service and other unit files, .conf files, .policy files, etc), are left as is. My assumption is that SPDX identifiers are not yet that well known, so it's better to retain the extended header to avoid any doubt. I also kept any copyright lines. We can probably remove them, but it'd nice to obtain explicit acks from all involved authors before doing that.
* tree-wide: use TAKE_PTR() and TAKE_FD() macrosYu Watanabe2018-04-051-2/+1
|
* Add SPDX license identifiers to source files under the LGPLZbigniew Jędrzejewski-Szmek2017-11-193-0/+3
| | | | | This follows what the kernel is doing, c.f. https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=5fd54ace4721fc5ce2bb5aef6318fcf17f421460.
* build-sys: use #if Y instead of #ifdef Y everywhereZbigniew Jędrzejewski-Szmek2017-10-041-1/+1
| | | | | | | | | | | | | | | The advantage is that is the name is mispellt, cpp will warn us. $ git grep -Ee "conf.set\('(HAVE|ENABLE)_" -l|xargs sed -r -i "s/conf.set\('(HAVE|ENABLE)_/conf.set10('\1_/" $ git grep -Ee '#ifn?def (HAVE|ENABLE)' -l|xargs sed -r -i 's/#ifdef (HAVE|ENABLE)/#if \1/; s/#ifndef (HAVE|ENABLE)/#if ! \1/;' $ git grep -Ee 'if.*defined\(HAVE' -l|xargs sed -i -r 's/defined\((HAVE_[A-Z0-9_]*)\)/\1/g' $ git grep -Ee 'if.*defined\(ENABLE' -l|xargs sed -i -r 's/defined\((ENABLE_[A-Z0-9_]*)\)/\1/g' + manual changes to meson.build squash! build-sys: use #if Y instead of #ifdef Y everywhere v2: - fix incorrect setting of HAVE_LIBIDN2
* build-sys: drop automake supportZbigniew Jędrzejewski-Szmek2017-07-181-1/+0
| | | | | v2: - also mention m4
* sd-hwdb: drop caching of search stringZbigniew Jędrzejewski-Szmek2016-11-301-23/+1
| | | | | We have only two callers, and for neither this "optimization" is useful. So let's drop it an save some code and a malloc.
* hwdb, sd-hwdb: rework priority comparison when loading propertiesZbigniew Jędrzejewski-Szmek2016-11-302-5/+35
| | | | | | | | | | | | | | | | | | | | | | | We cannot compare filenames directly, because paths are not sortable lexicographically, e.g. /etc/udev is "later" (has higher priority) than /usr/lib/udev. The on-disk format is changed to have a separate field for "file priority", which is stored when writing the binary file, and then loaded and used in comparisons. For data in the previous format (as generated by systemd 232), this information is not available, and we use a trick where the offset into the string table is used as a proxy for priority. Most of the time strings are stored in the order in which the files were processed. This is not entirely reliable, but is good enough to properly order /usr/lib and /etc/, which are the two most common cases. This hack is included because it allows proper parsing of files until the binary hwdb is regenerated. Instead of adding a new field, I reduced the size of line_number from 64 to 32 bits, and added a 16 bit priority field, and 16 bits of padding. Adding a new field of 16 bytes would significantly screw up alignment and increase file size, and line number realistically don't need more than ~20 bits. Fixes #4750.
* Two small cleanupsZbigniew Jędrzejewski-Szmek2016-11-291-1/+1
|
* hwdb: use systemd-hwdb instead of obsolete udevadm hwdb (#4722)Michael Biebl2016-11-231-1/+1
| | | Fixes: #4721
* sd-hwdb: order properties by originDavid Herrmann2016-09-211-15/+28
| | | | | | | | | | | If we find duplicates in a property-lookup, make sure to order them by their origin. That is, matches defined "later" take precedence over earlier matches. The "later"-order is defined by file-name + line-number combination. That is, if a match is defined below another one in the same hwdb file, it takes precedence, same as if it is defined in a file ordered after another one. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
* hwdb: store file-name and file-number with propertiesDavid Herrmann2016-09-211-0/+8
| | | | | | | | | | | Extend the hwdb to store the source file-name and file-number for each property. We simply extend the stored value struct with the new information. It is fully backwards compatible and old readers will continue to work. The libudev/sd-hwdb reader is updated in a followup. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
* sd-hwdb: fix child/value offset calculationDavid Herrmann2016-09-211-9/+14
| | | | | | | | | It is not legal to use hard-coded types to calculate offsets. We must always use the offsets of the hwdb header to calculate those. Otherwise, we will break horribly if run on hwdb files written by other implementations or written with future extensions. Signed-off-by: David Herrmann <dh.herrmann@gmail.com>
* tree-wide: place #pragma once at the same place everywhereLennart Poettering2016-02-201-1/+2
| | | | | | Usually, we place the #pragma once before the copyright blurb in header files, but in a few cases we didn't. Move those around, so that we do the same thing everywhere.
* tree-wide: remove Emacs lines from all filesDaniel Mack2016-02-101-2/+0
| | | | | This should be handled fine now by .dir-locals.el, so need to carry that stuff in every file.
* tree-wide: expose "p"-suffix unref calls in public APIs to make gcc cleanup easyLennart Poettering2015-11-272-4/+1
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | GLIB has recently started to officially support the gcc cleanup attribute in its public API, hence let's do the same for our APIs. With this patch we'll define an xyz_unrefp() call for each public xyz_unref() call, to make it easy to use inside a __attribute__((cleanup())) expression. Then, all code is ported over to make use of this. The new calls are also documented in the man pages, with examples how to use them (well, I only added docs where the _unref() call itself already had docs, and the examples, only cover sd_bus_unrefp() and sd_event_unrefp()). This also renames sd_lldp_free() to sd_lldp_unref(), since that's how we tend to call our destructors these days. Note that this defines no public macro that wraps gcc's attribute and makes it easier to use. While I think it's our duty in the library to make our stuff easy to use, I figure it's not our duty to make gcc's own features easy to use on its own. Most likely, client code which wants to make use of this should define its own: #define _cleanup_(function) __attribute__((cleanup(function))) Or similar, to make the gcc feature easier to use. Making this logic public has the benefit that we can remove three header files whose only purpose was to define these functions internally. See #2008.
* util-lib: split out allocation calls into alloc-util.[ch]Lennart Poettering2015-10-271-0/+1
|
* util-lib: split out fd-related operations into fd-util.[ch]Lennart Poettering2015-10-251-0/+1
| | | | | There are more than enough to deserve their own .c file, hence move them over.
* util-lib: split our string related calls from util.[ch] into its own file ↵Lennart Poettering2015-10-242-8/+8
| | | | | | | | | | | | | | string-util.[ch] There are more than enough calls doing string manipulations to deserve its own files, hence do something about it. This patch also sorts the #include blocks of all files that needed to be updated, according to the sorting suggestions from CODING_STYLE. Since pretty much every file needs our string manipulation functions this effectively means that most files have sorted #include blocks now. Also touches a few unrelated include files.
* util: introduce common version() implementation and use it everywhereLennart Poettering2015-09-291-0/+1
| | | | | | This also allows us to drop build.h from a ton of files, hence do so. Since we touched the #includes of those files, let's order them properly according to CODING_STYLE.
* util: introduce safe_fclose() and port everything over to itLennart Poettering2015-09-091-2/+1
| | | | Adds a coccinelle script to port things over automatically.
* tree-wide: we place the opening bracket on the same line as the function nameLennart Poettering2015-08-271-7/+6
| | | | Let's do this everywhere the same way.
* hashmap: fix iterators to not skip entriesDavid Herrmann2015-06-141-2/+3
| | | | | | | | | | | | | | | Currently, the HASHMAP iterators stop at the first NULL entry in a hashmap. This is non-obvious and breaks users like sd-device, which legitimately store NULL values in a hashmap. Fix all the iterators by taking a pointer to the value storage, instead of returning it. The iterators now return a boolean that tells whether the end of the list was reached. Current users of HASHMAP_FOREACH() are *NOT* changed to explicitly check for NULL. If it turns out, there were users that inserted NULL into hashmaps, but didn't properly check for it during iteration, then we really want to find those and fix them.
* fix double semicolon typoThomas Hindoe Paaboel Andersen2015-06-021-1/+1
|