aboutsummaryrefslogtreecommitdiff
path: root/osc.c
diff options
context:
space:
mode:
authorCraig Barnes <craigbarnes@protonmail.com>2021-10-20 16:05:36 +0000
committerCraig Barnes <craigbarnes@protonmail.com>2021-10-20 16:05:36 +0000
commit2e878892792e36f47a8ed5caea7bd56c75c1c626 (patch)
tree5a66e9eafd291c2f1aaa2ecf2ba48c46b5405e54 /osc.c
parentMerge branch 'nordiq' (diff)
osc: use STRLEN() macro to make parse_rgb() more self-documenting
The empty literals in the macro are to ensure the argument itself is a string literal, so it can't be used on anything else.
Diffstat (limited to 'osc.c')
-rw-r--r--osc.c7
1 files changed, 3 insertions, 4 deletions
diff --git a/osc.c b/osc.c
index eb1a6064..5cff3f34 100644
--- a/osc.c
+++ b/osc.c
@@ -11,6 +11,7 @@
#include "base64.h"
#include "config.h"
#include "grid.h"
+#include "macros.h"
#include "notify.h"
#include "render.h"
#include "selection.h"
@@ -341,12 +342,10 @@ parse_rgb(const char *string, uint32_t *color, bool *_have_alpha,
/* Verify we have the minimum required length (for "") */
if (have_alpha) {
- /* rgba:x/x/x/x */
- if (len < 4 /* 'rgba' */ + 1 /* ':' */ + 3 /* '/' */ + 4 * 1 /* 4 * 'x' */)
+ if (len < STRLEN("rgba:x/x/x/x"))
return false;
} else {
- /* rgb:x/x/x */
- if (len < 3 /* 'rgb' */ + 1 /* ':' */ + 2 /* '/' */ + 3 * 1 /* 3 * 'x' */)
+ if (len < STRLEN("rgb:x/x/x"))
return false;
}