The compiler generates following remark on it (first 2 lines in red):
In function 'boolean prepSDString(char*, int8_t, boolean)',
inlined from 'boolean prepSDString(char*, int8_t, boolean)' at H:\Arduino\examples\GSM_Shield_gboard_pro\WDFA_Teensy\WDFA_Teensy.ino:736:9:
WDFA_Teensy:741: warning: 'char* strncpy(char*, const char*, size_t)' output may be truncated copying 249 bytes from a string of length 250
741 | strncpy((char*)(talk_buff + 512), (char*)gsm.comm_buf, COMM_BUF_LEN-1); // Inhalt von comm_buf retten
nothing else, no warning, no error.
The sketch runs as expected.
Nevertheless I'd like to know why the compiler makes this remark.
(IDE 1.8.19 on Win10-64bit, compilation for a Teensy 3.2)
You'll need to look at the code it made that remark about. Or show it to someone and ask them. Nobody here is good enough to diagnose your code without being able to see it.
It's not a remark, it's a warning. You've copied all but the last location in a buffer to some other place. Compiler's warning you that you may have left behind something important, presumably it could be the string termination.
That's how I'd read it, anyway. You've probably got your warnings turned up(verbose), and sometimes the messages feel like handholding, but sometimes they point at something important you've missed.
I think your warning says you copied only part of a buffer (truncate means "make short"). Function call on line 736, offending action on line 741... COMM_BUF_LEN-1
The whole Sketch is quite big, but here is more around the critical part:
#define COMM_BUF_LEN 250 // from another header file, GSM_GP.h
uint8_t comm_buf[COMM_BUF_LEN+1]; // from the same header file
...
... from here in my sketch:
uint8_t talk_buff[1024];
...
boolean prepSDString(char* what, int8_t stat, boolean ausgeben) {
if (SDErrHTTP && (actsec_out < maxsec_out - 1)) {
talk_buff[0] = 42; // *
talk_buff[1] = 35; // #
talk_buff[2] = 0; // damit strcat angewandt werden kann
strncpy((char*)(talk_buff + 512), (char*)gsm.comm_buf, COMM_BUF_LEN); // Inhalt von comm_buf retten
...
The meaning of the code:
The content of gsm.comm_buf (250 bytes) shall be intermediately saved in the upper 512 bytes (enough space) of talk_buf. To ease copying, i.e. use strncpy(), the byte arrays are converted to char arrays.
Here, I guess, the compiler warns that at copying a string, don't forget the terminating 0, is'nt it?