[systemd-devel] split util.[ch] ?

Lennart Poettering lennart at poettering.net
Fri Apr 10 09:28:06 PDT 2015


On Fri, 10.04.15 18:19, Ronny Chevalier (chevalier.ronny at gmail.com) wrote:

> Hi,
> 
> Every time src/shared/util.h is modified nearly all systemd code base
> needs to be rebuilt, since it is included in lots of files (402/1029)
> 
> I think it would be great to split util.[ch] in multiple files (like
> with copy.c, file-io.c, ...), and I think there is plenty of functions
> that can be moved away of util.c.
> - util-escape: Functions related to escaping
> - util-string: Functions/macros like streq, strempty, endswith,...
> - util-process: Functions that fetch process information
> - util-safe: Functions that convert string to i64, u64, li, u16,...
> - util-random: Functions to get random bytes, u64,...
> - util-terminal: Functions/macros related to terminals/tty
> - [...]
> 
> What do you think?
> Is it worth it?

Yeah, we probably should do that.

But so far we called those split out files foo-util.h rather than
util-foo.h, and we should probably stick to that:

$ ls src/shared/*util*.h
src/shared/acl-util.h src/shared/cgroup-util.h src/shared/fstab-util.h
src/shared/in-addr-util.h src/shared/path-util.h
src/shared/socket-util.h src/shared/util.h src/shared/apparmor-util.h
src/shared/clock-util.h src/shared/fw-util.h src/shared/locale-util.h
src/shared/seccomp-util.h src/shared/sysctl-util.h
src/shared/blkid-util.h src/shared/env-util.h src/shared/ima-util.h
src/shared/memfd-util.h src/shared/selinux-util.h
src/shared/time-util.h src/shared/btrfs-util.h
src/shared/ether-addr-util.h src/shared/import-util.h
src/shared/nss-util.h src/shared/smack-util.h src/shared/udev-util.h

And I'd prefer to split this out slowly. For now I think having
process-util.[ch], random-util.[ch] and terminal-util.[ch] would make
sense, and we can look into the rest afterwards?

(simply because the lines between string handling, escaping strings
and parsing strings is so blurry...)

Lennart

-- 
Lennart Poettering, Red Hat


More information about the systemd-devel mailing list