xmalloc/xsnprintf: use x-wrapper functions in a few more places
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Craig Barnes · committed by Craig Barnes · parent ab9a3dc · Browse files · 4 files·+8 added−14 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
4 files+8 added−14 removed
- other:+8 added−14 removed
Provenance
- Commit
dfed80e- Tree
2e54a34- Author
Craig Barnes <craigbarnes@protonmail.com>- Committer
Craig Barnes <craigbarnes@protonmail.com>- Parent
ab9a3dc
4 files changed+8 added−14 removed
modified:config.c+3 added-10 removed
727 unmodified lines728 LOG_CONTEXTUAL_ERRNO("failed to expand '~'");729 return false;730 }731 732- if (asprintf(&_include_path, "%s/%s", home_dir, value + 2) < 0) {733- LOG_ERRNO("failed to allocate path for include directive");734- return false;735- }732+ _include_path = xstrjoin3(home_dir, "/", value + 2);733 include_path = _include_path;734 } else735 include_path = value;736 828 unmodified lines1565 {BIND_ACTION_CUSTOM_19, m_alt, {{XKB_KEY_parenleft}}},1566 };1567 1568 conf->key_bindings.count = ALEN(bindings);1572- conf->key_bindings.arr = xmalloc(sizeof(bindings));1573- memcpy(conf->key_bindings.arr, bindings, sizeof(bindings));1569+ conf->key_bindings.arr = xmemdup(bindings, sizeof(bindings));1570 }1571 1572 bool1573 config_load(struct config *conf, const char *conf_path,81 unmodified lines1655 struct config_file conf_file = {.path = NULL, .fd = -1};1656 1657 const char *terminal = getenv("TERMINAL");1658 if (terminal != NULL) {1663- if (asprintf(&conf->terminal, "%s -e", terminal) < 0) {1664- LOG_ERRNO("failed to build default terminal command line");1665- goto out;1666- }1659+ conf->terminal = xstrjoin(terminal, " -e");1660 }1661 1662 if (conf_path != NULL) {1663 int fd = open(conf_path, O_RDONLY);67 unmodified linesmodified:main.c+2 added-2 removed
264 unmodified lines265 }266 }267 268 char count_as_str[11];269- sprintf(count_as_str, "%u", apps->v[i]->count);270- const size_t count_len = strlen(count_as_str);269+ const size_t count_len = xsnprintf(270+ count_as_str, sizeof(count_as_str), "%u", apps->v[i]->count);271 272 if (write(fd, "|", 1) != 1 ||273 write(fd, count_as_str, count_len) != count_len ||274 write(fd, "\n", 1) != 1)1710 unmodified linesmodified:match.c+2 added-1 removed
27 unmodified lines28 #include "log.h"29 #include "char32.h"30 #include "wayland.h"31 #include "xmalloc.h"32+#include "xsnprintf.h"33 34 #define min(x, y) ((x < y) ? (x) : (y))35 #define max(x, y) ((x > y) ? (x) : (y))36 1254 unmodified lines1291 sigfillset(&mask);1292 pthread_sigmask(SIG_SETMASK, &mask, NULL);1293 1294 char proc_title[16];1294- snprintf(proc_title, sizeof(proc_title), "fuzzel:match:%d", my_id);1295+ xsnprintf(proc_title, sizeof(proc_title), "fuzzel:match:%d", my_id);1296 1297 if (pthread_setname_np(pthread_self(), proc_title) < 0)1298 LOG_ERRNO("render worker %d: failed to set process title", my_id);1299 349 unmodified linesmodified:render.c+1 added-1 removed
1157 unmodified lines1158 sigfillset(&mask);1159 pthread_sigmask(SIG_SETMASK, &mask, NULL);1160 1161 char proc_title[16];1162- snprintf(proc_title, sizeof(proc_title), "fuzzel:rend:%d", my_id);1162+ xsnprintf(proc_title, sizeof(proc_title), "fuzzel:rend:%d", my_id);1163 1164 if (pthread_setname_np(pthread_self(), proc_title) < 0)1165 LOG_ERRNO("render worker %d: failed to set process title", my_id);1166 287 unmodified lines