kore

An easy to use, scalable and secure web application framework for writing web APIs in C.
Commits | Files | Refs | README | LICENSE | git clone https://git.kore.io/kore.git

commit f8c9e736e2a376a88d31af6172c1e6765ac23015
parent 509142e1008a8c58676f5e770715d7f7b7b4a9c0
Author: Joris Vink <joris@coders.se>
Date:   Mon,  6 Mar 2017 22:48:19 +0100

don't depend on \n for NUL-terminating, just do it.

Diffstat:
src/cli.c | 12+++---------
1 file changed, 3 insertions(+), 9 deletions(-)

diff --git a/src/cli.c b/src/cli.c @@ -656,9 +656,7 @@ cli_reload(int argc, char **argv) cli_file_open("kore.pid", O_RDONLY, &fd); cli_file_read(fd, &buf, &len); cli_file_close(fd); - - if (buf[len - 1] == '\n') - buf[len - 1] = '\0'; + buf[len - 1] = '\0'; pid = cli_strtonum(buf, 0, UINT_MAX); @@ -1777,9 +1775,7 @@ cli_build_ldflags(struct buildopt *bopt) cli_file_open(".objs/ldflags", O_RDONLY, &fd); cli_file_read(fd, &buf, &len); cli_file_close(fd); - - if (buf[len - 1] == '\n') - buf[len - 1] = '\0'; + buf[len - 1] = '\0'; cli_buf_append(bopt->ldflags, buf, len); cli_buf_appendf(bopt->ldflags, " "); @@ -1847,9 +1843,7 @@ cli_kore_features(struct buildopt *bopt, char **out, size_t *outlen) cli_file_read(fd, &data, &len); cli_file_close(fd); free(path); - - if (data[len - 1] == '\n') - data[len - 1] = '\0'; + data[len - 1] = '\0'; *out = data; *outlen = len;