Fix compiler warning in conjunction with strncpy

pull/1/head
Andreas Eversberg 5 years ago
parent 3438402fe2
commit 4e2ad7dae1
  1. 6
      src/amps/frame.c
  2. 2
      src/bnetz/bnetz.c
  3. 2
      src/cnetz/transaction.h
  4. 2
      src/libdisplay/display_measurements.c
  5. 6
      src/libdisplay/display_status.c
  6. 4
      src/libsdr/sdr.c

@ -3343,7 +3343,7 @@ static void amps_encode_focc_bits(uint64_t word_a, uint64_t word_b, char *bits)
{
int i, j, k;
strncpy(bits + 0, dotting, 10);
memcpy(bits + 0, dotting, 10);
bits[10] = 'i';
strcpy(bits + 11, sync_word);
bits[22] = 'i';
@ -3391,10 +3391,10 @@ static void amps_encode_fvc_bits(uint64_t word_a, char *bits)
k = 0;
for (i = 0; i < 11; i++) {
if (i == 0) {
strncpy(bits + k, dotting, 101);
memcpy(bits + k, dotting, 101);
k += 101;
} else {
strncpy(bits + k, dotting, 37);
memcpy(bits + k, dotting, 37);
k += 37;
}
strcpy(bits + k, sync_word);

@ -161,7 +161,7 @@ int bnetz_create(int kanal, const char *audiodev, int use_sdr, int samplerate, d
{
bnetz_t *bnetz;
enum paging_signal paging_signal = PAGING_SIGNAL_NONE;
char paging_file[256] = "", paging_on[256] = "", paging_off[256] = "";
char paging_file[255] = "", paging_on[255] = "", paging_off[255] = "";
int rc;
if (!(kanal >= 1 && kanal <= 39) && !(kanal >= 50 && kanal <= 86)) {

@ -40,7 +40,7 @@ typedef struct transaction {
uint8_t futln_fuvst;
uint16_t futln_rest;
int extended; /* extended frequency capability */
char dialing[17]; /* number dialed by the phone */
char dialing[18]; /* number dialed by the phone */
int64_t state; /* state of transaction */
int8_t release_cause; /* reason for release, (c-netz coding) */
int try; /* counts resending messages */

@ -202,7 +202,7 @@ static void print_measurements(int on)
break;
}
/* "Deviation ::::::::::............ 4.5 KHz" */
strncpy(line, param->name, (strlen(param->name) < MAX_NAME_LEN) ? strlen(param->name) : MAX_NAME_LEN);
memcpy(line, param->name, (strlen(param->name) < MAX_NAME_LEN) ? strlen(param->name) : MAX_NAME_LEN);
if (isinf(value) || isnan(value)) {
bar_left = -1;
bar_right = -1;

@ -83,7 +83,7 @@ void display_status_start(void)
{
memset(screen, ' ', sizeof(screen));
memset(screen[0], '-', sizeof(screen[0]));
strncpy(screen[0] + 4, "Channel Status", 14);
memcpy(screen[0] + 4, "Channel Status", 14);
line_count = 1;
}
@ -103,7 +103,7 @@ void display_status_channel(int channel, const char *type, const char *state)
else
snprintf(line, sizeof(line), "Channel: %d State: %s", channel, state);
line[sizeof(line) - 1] = '\0';
strncpy(screen[line_count++], line, strlen(line));
memcpy(screen[line_count++], line, strlen(line));
}
void display_status_subscriber(const char *number, const char *state)
@ -118,7 +118,7 @@ void display_status_subscriber(const char *number, const char *state)
else
snprintf(line, sizeof(line), " Subscriber: %s", number);
line[sizeof(line) - 1] = '\0';
strncpy(screen[line_count++], line, strlen(line));
memcpy(screen[line_count++], line, strlen(line));
}
void display_status_end(void)

@ -562,7 +562,7 @@ int sdr_start(void *inst)
return rc;
}
pthread_getname_np(tid, tname, sizeof(tname));
strncat(tname, "-sdr_tx", sizeof(tname));
strncat(tname, "-sdr_tx", sizeof(tname) - 1);
tname[sizeof(tname) - 1] = '\0';
pthread_setname_np(tid, tname);
sdr->thread_read.running = 1;
@ -574,7 +574,7 @@ int sdr_start(void *inst)
return rc;
}
pthread_getname_np(tid, tname, sizeof(tname));
strncat(tname, "-sdr_rx", sizeof(tname));
strncat(tname, "-sdr_rx", sizeof(tname) - 1);
tname[sizeof(tname) - 1] = '\0';
pthread_setname_np(tid, tname);
}

Loading…
Cancel
Save