summaryrefslogtreecommitdiff
path: root/src/shared/install.c
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-03-24 19:59:00 -0400
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2013-04-05 19:50:57 -0400
commitb92bea5d2a9481de69bb627a7b442a9f58fca43d (patch)
treed43f5e340014d5c3ce723eabb60cd74e3dd20a18 /src/shared/install.c
parent8c62ecf1a99ab4a3f69cb81be38715c504ef5723 (diff)
Use initalization instead of explicit zeroing
Before, we would initialize many fields twice: first by filling the structure with zeros, and then a second time with the real values. We can let the compiler do the job for us, avoiding one copy. A downside of this patch is that text gets slightly bigger. This is because all zero() calls are effectively inlined: $ size build/.libs/systemd text data bss dec hex filename before 897737 107300 2560 1007597 f5fed build/.libs/systemd after 897873 107300 2560 1007733 f6075 build/.libs/systemd … actually less than 1‰. A few asserts that the parameter is not null had to be removed. I don't think this changes much, because first, it is quite unlikely for the assert to fail, and second, an immediate SEGV is almost as good as an assert.
Diffstat (limited to 'src/shared/install.c')
-rw-r--r--src/shared/install.c24
1 files changed, 12 insertions, 12 deletions
diff --git a/src/shared/install.c b/src/shared/install.c
index 2555a36c0a..9e870392f2 100644
--- a/src/shared/install.c
+++ b/src/shared/install.c
@@ -700,7 +700,7 @@ int unit_file_link(
UnitFileChange **changes,
unsigned *n_changes) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
char **i;
char _cleanup_free_ *config_path = NULL;
int r, q;
@@ -1116,7 +1116,7 @@ static int unit_file_can_install(
const char *name,
bool allow_symlink) {
- InstallContext _cleanup_install_context_done_ c = {NULL};
+ InstallContext _cleanup_install_context_done_ c = {};
InstallInfo *i;
int r;
@@ -1452,8 +1452,8 @@ int unit_file_enable(
UnitFileChange **changes,
unsigned *n_changes) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
- InstallContext _cleanup_install_context_done_ c = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
+ InstallContext _cleanup_install_context_done_ c = {};
char **i;
char _cleanup_free_ *config_path = NULL;
int r;
@@ -1491,8 +1491,8 @@ int unit_file_disable(
UnitFileChange **changes,
unsigned *n_changes) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
- InstallContext _cleanup_install_context_done_ c = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
+ InstallContext _cleanup_install_context_done_ c = {};
char **i;
char _cleanup_free_ *config_path = NULL;
Set _cleanup_set_free_free_ *remove_symlinks_to = NULL;
@@ -1533,8 +1533,8 @@ int unit_file_reenable(
UnitFileChange **changes,
unsigned *n_changes) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
- InstallContext _cleanup_install_context_done_ c = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
+ InstallContext _cleanup_install_context_done_ c = {};
char **i;
char _cleanup_free_ *config_path = NULL;
Set _cleanup_set_free_free_ *remove_symlinks_to = NULL;
@@ -1576,7 +1576,7 @@ UnitFileState unit_file_get_state(
const char *root_dir,
const char *name) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
UnitFileState state = _UNIT_FILE_STATE_INVALID;
char **i;
char _cleanup_free_ *path = NULL;
@@ -1734,8 +1734,8 @@ int unit_file_preset(
UnitFileChange **changes,
unsigned *n_changes) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
- InstallContext _cleanup_install_context_done_ plus = {NULL}, minus = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
+ InstallContext _cleanup_install_context_done_ plus = {}, minus = {NULL};
char **i;
char _cleanup_free_ *config_path = NULL;
Set _cleanup_set_free_free_ *remove_symlinks_to = NULL;
@@ -1800,7 +1800,7 @@ int unit_file_get_list(
const char *root_dir,
Hashmap *h) {
- LookupPaths _cleanup_lookup_paths_free_ paths = {NULL};
+ LookupPaths _cleanup_lookup_paths_free_ paths = {};
char **i;
char _cleanup_free_ *buf = NULL;
DIR _cleanup_closedir_ *d = NULL;