diff --git a/GPSBabel.pro b/GPSBabel.pro index 75abb6ba7..0b91485a2 100644 --- a/GPSBabel.pro +++ b/GPSBabel.pro @@ -268,3 +268,6 @@ linux{ coverage.commands += genhtml coverage.info --output-directory coverage_report; QMAKE_EXTRA_TARGETS += coverage } + +cppcheck.commands = cppcheck --enable=all --force --config-exclude=zlib --config-exclude=shapelib $(INCPATH) $$ALL_FMTS $$FILTERS $$SUPPORT $$JEEPS +QMAKE_EXTRA_TARGETS += cppcheck diff --git a/mapsource.cc b/mapsource.cc index 146eb2f06..647065dca 100644 --- a/mapsource.cc +++ b/mapsource.cc @@ -1476,7 +1476,7 @@ mps_track_r(gbfile* mps_file, int mps_ver, route_head** trk) return; } #ifdef MPS_DEBUG - fprintf(stderr, "mps_track_r: there are %d track waypoints %d\n", trk_count); + fprintf(stderr, "mps_track_r: there are %d track waypoints\n", trk_count); #endif track_head = route_head_alloc(); diff --git a/mtk_logger.cc b/mtk_logger.cc index 00b96396d..28683854c 100644 --- a/mtk_logger.cc +++ b/mtk_logger.cc @@ -304,7 +304,8 @@ static void dbg(int l, const char* msg, ...) // // It returns a temporary C string - it's totally kludged in to replace // TEMP_DATA_BIN being string constants. -static const QString GetTempName(bool backup) { +static const QString GetTempName(bool backup) +{ const char kData[]= "data.bin"; const char kDataBackup[]= "data_old.bin"; return QDir::tempPath() + QDir::separator() + (backup ? kDataBackup : kData); @@ -555,7 +556,6 @@ static void mtk_read() if (dout == nullptr) { fatal(MYNAME ": Can't create temporary file %s", qPrintable(TEMP_DATA_BIN)); - return; } } fseek(dout, 0L,SEEK_END); @@ -611,7 +611,6 @@ static void mtk_read() if (dout == nullptr) { fatal(MYNAME ": Can't create temporary file %s", qPrintable(TEMP_DATA_BIN)); - return; } } @@ -818,11 +817,11 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) sprintf(spds, " when moving above %.0f km/h", mtk_info.speed/10.); } trk_head->rte_desc = QString().sprintf("Log every %.0f sec, %.0f m%s" - , mtk_info.period/10., mtk_info.distance/10., spds); + , mtk_info.period/10., mtk_info.distance/10., spds); track_add_head(trk_head); } - if (bmask & (1<latitude = itm->lat; trk->longitude = itm->lon; } else { @@ -830,31 +829,31 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) return -1; // GPX requires lat/lon... } - if (bmask & (1<altitude = itm->height; } trk->SetCreationTime(itm->timestamp); // in UTC.. - if (bmask & (1<creation_time = trk->creation_time.addMSecs(itm->timestamp_ms); } - if (bmask & (1<pdop = itm->pdop; } - if (bmask & (1<hdop = itm->hdop; } - if (bmask & (1<vdop = itm->vdop; } - if (bmask & (1<heading); } - if (bmask & (1<speed)); } - if (bmask & (1<valid) { case 0x0040: trk->fix = fix_unknown; @@ -890,14 +889,14 @@ static int add_trackpoint(int idx, unsigned long bmask, struct data_item* itm) return -1; } } - if (bmask & (1<sat = itm->sat_used; } // RCR is a bitmask of possibly several log reasons.. // Holux devics use a Event prefix for each waypt. if (global_opts.masked_objective & WPTDATAMASK - && ((bmask & (1<rcr & 0x0008) + && ((bmask & (1U<rcr & 0x0008) || (mtk_info.track_event & MTK_EVT_WAYPT) ) ) { @@ -943,10 +942,10 @@ static void mtk_csv_init(char* csv_fname, unsigned long bitmask) } /* Add the header line */ - gbfprintf(cd, "INDEX,%s%s", ((1<timestamp)); strftime(ts_str, sizeof(ts_str)-1, "%Y/%m/%d,%H:%M:%S", ts_tm); - if (bmask & (1<valid) { case 0x0001: fix_str = "No fix"; @@ -1030,56 +1029,56 @@ static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, struct data_i gbfprintf(csvFile, "%d,", idx); // RCR is a bitmask of possibly several log reasons.. - if (bmask & (1<rcr&0x0001?"T":"",itm->rcr&0x0002?"S":"" - , itm->rcr&0x0004?"D":"",itm->rcr&0x0008?"B":""); + , (itm->rcr&0x0001)?"T":"", (itm->rcr&0x0002)?"S":"" + , (itm->rcr&0x0004)?"D":"", (itm->rcr&0x0008)?"B":""); - if (bmask & (1<timestamp_ms:0); + if (bmask & (1U<timestamp_ms:0); } - if (bmask & (1<lat), itm->lat>0?'N':'S', fabs(itm->lon), itm->lon>0?'E':'W'); - if (bmask & (1<height); } - if (bmask & (1<speed); } - if (bmask & (1<heading); } - if (bmask & (1<dsta); } - if (bmask & (1<dage); } - if (bmask & (1<pdop); } - if (bmask & (1<hdop); // note bug in MTK appl. 1.02 is output as 1.2 ! } - if (bmask & (1<vdop); } - if (bmask & (1<sat_used, itm->sat_view); } - if (bmask & (1<sat_count; l++) { @@ -1087,23 +1086,23 @@ static int csv_line(gbfile* csvFile, int idx, unsigned long bmask, struct data_i slen += sprintf(&sstr[slen], "%s%.2d" , itm->sat_data[l].used?"#":"" , itm->sat_data[l].id); - if (bmask & (1<sat_data[l].elevation); } - if (bmask & (1<sat_data[l].azimut); } - if (bmask & (1<sat_data[l].snr); } - gbfprintf(csvFile, "%s%s" , do_sc?";":"", sstr); + gbfprintf(csvFile, "%s%s", do_sc?";":"", sstr); do_sc = 1; } gbfprintf(csvFile, ","); } - if (bmask & (1<distance); } @@ -1135,28 +1134,28 @@ static int mtk_parse(unsigned char* data, int dataLen, unsigned int bmask) int i = 0; unsigned char crc = 0; for (int k = 0; k<32; k++) { - switch (((1< 0) { // handle 'Zero satellites in view issue' - if (bmask & (1< 0) { - if (bmask & (1< DISTANCE && global_opts.debug_level > 0) { warning(MYNAME ": Unknown size/meaning of bit %d\n", i); } - if ((i == SID || i == ELEVATION || i == AZIMUTH || i == SNR) && (1<