build: strncat warning in buf_write #39684

To make gcc happy
```
src/nvim/bufwrite.c: In function ‘buf_write’:
src/nvim/bufwrite.c:1674:5: warning: ‘strncat’ specified bound depends
on the length of the source argument [-Wstringop-overflow=]
 1674 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |     ^
src/nvim/bufwrite.c:1674:34: note: length computed here
 1674 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |                                  ^
src/nvim/fileio.c: In function ‘filemess’:
src/nvim/fileio.c:137:5: warning: ‘strncat’ specified bound depends on
the length of the source argument [-Wstringop-overflow=]
  137 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |     ^
src/nvim/fileio.c:137:34: note: length computed here
  137 |     strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
      |                                  ^
```
This commit is contained in:
phanium
2026-05-09 02:47:00 +08:00
committed by GitHub
parent 27909a193d
commit b7d8a41d91
2 changed files with 4 additions and 4 deletions

View File

@@ -1669,9 +1669,9 @@ restore_backup:
#endif
if (!filtering) {
add_quoted_fname(IObuff, IOSIZE, buf, fname);
// Append the filename to the message ID.
// Append the filename (without trailing char) to the message ID.
char msg_id[IOSIZE + 14] = "nvim.bufwrite ";
strncat(msg_id + 14, IObuff, strlen(IObuff) - 1);
xstrlcat(msg_id, IObuff, 14 + strlen(IObuff));
bool insert_space = false;
if (write_info.bw_conv_error) {
xstrlcat(IObuff, _(" CONVERSION ERROR"), IOSIZE);