Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Suppress "warning: 'strncpy' specified bound depends on the length of…
… the source argument" (#361) This patch will suppress the following warning with compiling gcc: ``` sax_buf.c: In function 'read_from_str': sax_buf.c:201:5: warning: 'strncpy' specified bound depends on the length of the source argument [-Wstringop-truncation] 201 | strncpy(buf->tail, buf->in.str, cnt); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ sax_buf.c:197:11: note: length computed here 197 | cnt = strlen(buf->in.str) + 1; | ^~~~~~~~~~~~~~~~~~~ ``` If strncpy is used, we should pass count argument as a value of source boundary. In this case, it might be `strncpy(buf->tail, buf->in.str, max);` This patch will use `memcpy` instead becaseu copied length is already known. Ref. https://stackoverflow.com/a/56782476
- Loading branch information