diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2020-07-10 14:57:57 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2020-07-13 18:41:00 +1000 |
commit | 41a7c975f8e5d1f4e74fd945f6f1aecc9ef4b498 (patch) | |
tree | 6cd4eb98fe11bb0410edd0452175fbd93bfb19e9 /src/compose | |
parent | 2cb90c958f7efa36b00fe845c38bbe0d00e15b1e (diff) | |
download | xorg-lib-libxkbcommon-41a7c975f8e5d1f4e74fd945f6f1aecc9ef4b498.tar.gz |
Add asprintf_safe helper function
We only ever care about whether we error out or not, so let's wrap this into
something more sane.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Diffstat (limited to 'src/compose')
-rw-r--r-- | src/compose/paths.c | 13 |
1 files changed, 3 insertions, 10 deletions
diff --git a/src/compose/paths.c b/src/compose/paths.c index f37c759..19eafa4 100644 --- a/src/compose/paths.c +++ b/src/compose/paths.c @@ -25,6 +25,7 @@ #include "utils.h" #include "paths.h" +#include "utils.h" enum resolve_name_direction { LEFT_TO_RIGHT, @@ -151,19 +152,13 @@ get_xcomposefile_path(void) char * get_home_xcompose_file_path(void) { - int ret; const char *home; - char *path; home = secure_getenv("HOME"); if (!home) return NULL; - ret = asprintf(&path, "%s/.XCompose", home); - if (ret <0) - return NULL; - - return path; + return asprintf_safe("%s/.XCompose", home); } char * @@ -195,10 +190,8 @@ get_locale_compose_file_path(const char *locale) } else { const char *xlocaledir = get_xlocaledir_path(); - int ret = asprintf(&path, "%s/%s", xlocaledir, resolved); + path = asprintf_safe("%s/%s", xlocaledir, resolved); free(resolved); - if (ret < 0) - return NULL; } return path; |