From cfbf2130daa43633b317c572829b3527be305857 Mon Sep 17 00:00:00 2001 From: Drew DeVault Date: Tue, 06 Nov 2018 11:31:26 -0500 Subject: [PATCH] Don't have side effects in assert --- src/main.c | 11 +++++++---- diff --git a/src/main.c b/src/main.c index 14b08d2fdce057e4a8648c4f780261d2d4aa30b7..08957bfa4f94304d0e5019495153c2d84bdcd57a 100644 --- a/src/main.c +++ b/src/main.c @@ -16,7 +16,8 @@ str_t *section = str_create(); uint32_t ch; while ((ch = parser_getch(p)) != UTF8_INVALID) { if (ch < 0x80 && isdigit(ch)) { - assert(str_append_ch(section, ch) != -1); + int ret = str_append_ch(section, ch); + assert(ret != -1); } else if (ch == ')') { if (!section->str) { break; @@ -72,7 +73,8 @@ struct tm *now_tm = localtime(&now); strftime(date, sizeof(date), "%F", now_tm); while ((ch = parser_getch(p)) != UTF8_INVALID) { if ((ch < 0x80 && isalnum(ch)) || ch == '_' || ch == '-' || ch == '.') { - assert(str_append_ch(name, ch) != -1); + int ret = str_append_ch(name, ch); + assert(ret != -1); } else if (ch == '(') { section = parse_section(p); } else if (ch == '"') { @@ -482,8 +484,9 @@ while ((ch = parser_getch(p)) != UTF8_INVALID) { switch (ch) { case '\n': goto commit_cell; - default: - assert(str_append_ch(curcell->contents, ch) != -1); + default:; + int ret = str_append_ch(curcell->contents, ch); + assert(ret != -1); break; } } -- 2.48.1