From f87c9bb9f70f1a6c8c7081c762c15ba7eaaf971e Mon Sep 17 00:00:00 2001 From: Craig Barnes Date: Sat, 3 Aug 2024 08:12:13 +0100 Subject: xmalloc: remove delim param from xstrjoin() and add separate xstrjoin3() This avoids the need for an unused third argument for most xstrjoin() calls and replaces the cases where it's needed with a more flexible function. Code generation is the same in both cases, when there are 2 string params and a compile-time known delimiter. This commit also converts 4 uses of xasprintf() to use xstrjoin*(). See also: https://godbolt.org/z/xsjrhv9b6 --- terminal.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 16de2d65..5699e6b5 100644 --- a/terminal.c +++ b/terminal.c @@ -994,7 +994,7 @@ reload_fonts(struct terminal *term, bool resize_grid) snprintf(size, sizeof(size), ":size=%.2f", term->font_sizes[i][j].pt_size * scale); - names[i][j] = xstrjoin(font->pattern, size, 0); + names[i][j] = xstrjoin(font->pattern, size); } } @@ -1021,9 +1021,9 @@ reload_fonts(struct terminal *term, bool resize_grid) char *attrs[4] = { [0] = dpi, /* Takes ownership */ - [1] = xstrjoin(dpi, !custom_bold ? ":weight=bold" : "", 0), - [2] = xstrjoin(dpi, !custom_italic ? ":slant=italic" : "", 0), - [3] = xstrjoin(dpi, !custom_bold_italic ? ":weight=bold:slant=italic" : "", 0), + [1] = xstrjoin(dpi, !custom_bold ? ":weight=bold" : ""), + [2] = xstrjoin(dpi, !custom_italic ? ":slant=italic" : ""), + [3] = xstrjoin(dpi, !custom_bold_italic ? ":weight=bold:slant=italic" : ""), }; struct fcft_font *fonts[4]; -- cgit v1.3 From a3a35f2c8c6ce3b35ec22627cb3097f621c46373 Mon Sep 17 00:00:00 2001 From: Daniel Eklöf Date: Sat, 3 Aug 2024 09:04:24 +0200 Subject: term: reload_fonts(): don't ignore return value of thrd_join() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This should fix the ‘ret’ may be used uninitialized warning Closes #1789 --- terminal.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'terminal.c') diff --git a/terminal.c b/terminal.c index 5699e6b5..fe97e958 100644 --- a/terminal.c +++ b/terminal.c @@ -1048,8 +1048,10 @@ reload_fonts(struct terminal *term, bool resize_grid) for (size_t i = 0; i < 4; i++) { if (tids[i] != 0) { int ret; - thrd_join(tids[i], &ret); - success = success && ret; + if (thrd_join(tids[i], &ret) != 0) + success = false; + else + success = success && ret; } else success = false; } -- cgit v1.3