Skip to content

Commit a743d12

Browse files
authored
Merge pull request LinuxCNC#3715 from BsAtHome/fix_strncat-warning
Fix strncat warning by using local small buffer.
2 parents 891b22b + 967e965 commit a743d12

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/emc/tooldata/tooldata_common.cc

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,12 +245,13 @@ void tooldata_format_toolline (int idx,
245245
space -= len;
246246
// format zero float values as %.0f for brevity
247247
#define F_ITEM(item,letter) if (!ignore_zero_values || tdata.item) { \
248+
char local_tmp[64] = {}; \
248249
if (tdata.item) { \
249-
len = snprintf(tmp,sizeof(tmp)," " letter "%+f", tdata.item); \
250+
len = snprintf(local_tmp,sizeof(local_tmp)," " letter "%+f", tdata.item); \
250251
} else { \
251-
len = snprintf(tmp,sizeof(tmp)," " letter "%.0f",tdata.item); \
252+
len = snprintf(local_tmp,sizeof(local_tmp)," " letter "%.0f",tdata.item); \
252253
} \
253-
strncat(formatted_line,tmp,space); \
254+
strncat(formatted_line,local_tmp,space); \
254255
space -= len; \
255256
}
256257
#define I_ITEM(item,letter) if (!ignore_zero_values || tdata.item) { \

0 commit comments

Comments
 (0)