Skip to content

Commit fa20067

Browse files
committed
Fix unterminated-string-initialization warning.
1 parent 1d3a01f commit fa20067

File tree

6 files changed

+26
-25
lines changed

6 files changed

+26
-25
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -222,13 +222,13 @@ showconfig:
222222
%.o: %.c *.h
223223
$(CC) $(ALL_CCFLAGS) -c $< -o $@
224224

225-
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o ais_charset.o adaptive.o $(SDR_OBJ) $(COMPAT) $(CPUFEATURES_OBJS) $(STARCH_OBJS)
225+
dump1090: dump1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o demod_2400.o stats.o cpr.o icao_filter.o track.o util.o convert.o adaptive.o $(SDR_OBJ) $(COMPAT) $(CPUFEATURES_OBJS) $(STARCH_OBJS)
226226
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_SDR) $(LIBS_CURSES)
227227

228-
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o ais_charset.o sdr_stub.o $(COMPAT)
228+
view1090: view1090.o anet.o interactive.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o sdr_stub.o $(COMPAT)
229229
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS) $(LIBS_CURSES)
230230

231-
faup1090: faup1090.o anet.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o ais_charset.o sdr_stub.o $(COMPAT)
231+
faup1090: faup1090.o anet.o mode_ac.o mode_s.o comm_b.o net_io.o crc.o stats.o cpr.o icao_filter.o track.o util.o sdr_stub.o $(COMPAT)
232232
$(CC) -g -o $@ $^ $(LDFLAGS) $(LIBS)
233233

234234
starch-benchmark: cpu.o dsp/helpers/tables.o $(CPUFEATURES_OBJS) $(STARCH_OBJS) $(STARCH_BENCHMARK_OBJ)
@@ -252,7 +252,7 @@ benchmarks: oneoff/convert_benchmark
252252
oneoff/convert_benchmark: oneoff/convert_benchmark.o convert.o util.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)
253253
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm -lpthread
254254

255-
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o ais_charset.o
255+
oneoff/decode_comm_b: oneoff/decode_comm_b.o comm_b.o
256256
$(CC) $(ALL_CCFLAGS) -g -o $@ $^ -lm
257257

258258
oneoff/dsp_error_measurement: oneoff/dsp_error_measurement.o dsp/helpers/tables.o cpu.o $(CPUFEATURES_OBJS) $(STARCH_OBJS)

ais_charset.c

Lines changed: 0 additions & 3 deletions
This file was deleted.

ais_charset.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
#ifndef AIS_CHARSET_H
22
#define AIS_CHARSET_H
33

4-
extern char ais_charset[64];
4+
// AIS character set is just the first 64 printable ASCII characters,
5+
// but with 0x20..0x3F after 0x40..0x5F.
6+
static inline __attribute__((always_inline)) char ais_to_ascii(unsigned i) {
7+
return (i + 0x20) ^ 0b01100000;
8+
}
59

610
#endif

comm_b.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -244,14 +244,14 @@ static int decodeBDS20(struct modesMessage *mm, bool store)
244244
return 0;
245245
}
246246

247-
callsign[0] = ais_charset[getbits(msg, 9, 14)];
248-
callsign[1] = ais_charset[getbits(msg, 15, 20)];
249-
callsign[2] = ais_charset[getbits(msg, 21, 26)];
250-
callsign[3] = ais_charset[getbits(msg, 27, 32)];
251-
callsign[4] = ais_charset[getbits(msg, 33, 38)];
252-
callsign[5] = ais_charset[getbits(msg, 39, 44)];
253-
callsign[6] = ais_charset[getbits(msg, 45, 50)];
254-
callsign[7] = ais_charset[getbits(msg, 51, 56)];
247+
callsign[0] = ais_to_ascii(getbits(msg, 9, 14));
248+
callsign[1] = ais_to_ascii(getbits(msg, 15, 20));
249+
callsign[2] = ais_to_ascii(getbits(msg, 21, 26));
250+
callsign[3] = ais_to_ascii(getbits(msg, 27, 32));
251+
callsign[4] = ais_to_ascii(getbits(msg, 33, 38));
252+
callsign[5] = ais_to_ascii(getbits(msg, 39, 44));
253+
callsign[6] = ais_to_ascii(getbits(msg, 45, 50));
254+
callsign[7] = ais_to_ascii(getbits(msg, 51, 56));
255255
callsign[8] = 0;
256256

257257
// score based on number of valid characters

interactive.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ void interactiveShowData(void) {
140140
static bool need_clear = true;
141141
uint64_t now = mstime();
142142
char progress;
143-
char spinner[4] = "|/-\\";
143+
char spinner[4] = {'|', '/', '-', '\\' };
144144
int valid = 0;
145145
double signalMax = -100.0;
146146
double signalMin = +100.0;

mode_s.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -802,14 +802,14 @@ static void decodeESIdentAndCategory(struct modesMessage *mm)
802802

803803
mm->mesub = getbits(me, 6, 8);
804804

805-
mm->callsign[0] = ais_charset[getbits(me, 9, 14)];
806-
mm->callsign[1] = ais_charset[getbits(me, 15, 20)];
807-
mm->callsign[2] = ais_charset[getbits(me, 21, 26)];
808-
mm->callsign[3] = ais_charset[getbits(me, 27, 32)];
809-
mm->callsign[4] = ais_charset[getbits(me, 33, 38)];
810-
mm->callsign[5] = ais_charset[getbits(me, 39, 44)];
811-
mm->callsign[6] = ais_charset[getbits(me, 45, 50)];
812-
mm->callsign[7] = ais_charset[getbits(me, 51, 56)];
805+
mm->callsign[0] = ais_to_ascii(getbits(me, 9, 14));
806+
mm->callsign[1] = ais_to_ascii(getbits(me, 15, 20));
807+
mm->callsign[2] = ais_to_ascii(getbits(me, 21, 26));
808+
mm->callsign[3] = ais_to_ascii(getbits(me, 27, 32));
809+
mm->callsign[4] = ais_to_ascii(getbits(me, 33, 38));
810+
mm->callsign[5] = ais_to_ascii(getbits(me, 39, 44));
811+
mm->callsign[6] = ais_to_ascii(getbits(me, 45, 50));
812+
mm->callsign[7] = ais_to_ascii(getbits(me, 51, 56));
813813
mm->callsign[8] = 0;
814814
mm->callsign_valid = 1;
815815

0 commit comments

Comments
 (0)