Use QUOTEDSTRLEN macro instead of sizeof or strlen

This commit is contained in:
Rangi42
2024-03-27 11:50:48 -04:00
parent 912a1504ec
commit dcb4e40388
5 changed files with 16 additions and 11 deletions

View File

@@ -10,6 +10,7 @@
#include <string.h>
#include "error.hpp"
#include "helpers.hpp" // QUOTEDSTRLEN
#include "itertools.hpp"
#include "asm/fstack.hpp"
@@ -230,8 +231,8 @@ void processWarningFlag(char const *flag) {
}
// If it's not a meta warning, specially check against `-Werror`
if (!strncmp(flag, "error", strlen("error"))) {
char const *errorFlag = flag + strlen("error");
if (!strncmp(flag, "error", QUOTEDSTRLEN("error"))) {
char const *errorFlag = flag + QUOTEDSTRLEN("error");
switch (*errorFlag) {
case '\0':
@@ -254,9 +255,9 @@ void processWarningFlag(char const *flag) {
WarningState state = setError ? WARNING_ERROR
// Not an error, then check if this is a negation
: strncmp(flag, "no-", strlen("no-")) ? WARNING_ENABLED
: WARNING_DISABLED;
char const *rootFlag = state == WARNING_DISABLED ? flag + strlen("no-") : flag;
: strncmp(flag, "no-", QUOTEDSTRLEN("no-")) ? WARNING_ENABLED
: WARNING_DISABLED;
char const *rootFlag = state == WARNING_DISABLED ? flag + QUOTEDSTRLEN("no-") : flag;
// Is this a "parametric" warning?
if (state != WARNING_DISABLED) { // The `no-` form cannot be parametrized