Skip to content

Commit

Permalink
fix various "Redundancies in code" (#1178)
Browse files Browse the repository at this point in the history
* fix "Redundant elaborted type specifier"

* fix "Redundant 'inline' specifier"

* fix "redundant 'const' specifier on a constexpr variable"

* remove "Redundant qualifier"

* add /out/, /.vs/ to .gitignore, and sort.
  • Loading branch information
tsteven4 authored Sep 14, 2023
1 parent 926f207 commit 2ff93fa
Show file tree
Hide file tree
Showing 18 changed files with 111 additions and 110 deletions.
62 changes: 32 additions & 30 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,21 @@
*.a
*.o
*.swp
.ninja_deps
.ninja_log
.qmake.cache
.qmake.stash
.qt
/*.gcda
/*.gcno
/*.gcov
/.vs/
/.vscode/
/GPSBabel
/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2
/GPSBabel[0-9]*.[0-9]*.[0-9]*/
/Makefile
/autogen/
/autom4te.cache/
/babelweb/
/bld/
Expand All @@ -8,46 +26,30 @@
/config.status
/cscope.out
/debug/
/empty
/gbversion.h
/gpsbabel
/gpsbabel-debug
/gpsbabel.exe
/gpsbabel.fo
/gpsbabel.gch/
/gpsbabel.html
/gpsbabel.pdf
/gpsbabel.rc
/gpsbabel_autogen/
/gpsbabel_coverage.xml
/Makefile
.qmake.cache
.qmake.stash
/GPSBabel
/*.gcda
/*.gcno
/*.gcov
*.o
*.a
.ninja_deps
.ninja_log
.qt
build.ninja
rules.ninja
cmake_install.cmake
CMakeCache.txt
CMakeFiles/
CTestTestfile.cmake
/GPSBabel[0-9]*.[0-9]*.[0-9]*/
/GPSBabel[0-9]*.[0-9]*.[0-9]*.tar.bz2
/makedoc
/makelinuxdist.sh
/mkcapabilities
/objects/
/out/
/qrc_gpsbabel.cpp
/release/
*.swp
/tmp/
/mkcapabilities
/gpsbabel.gch/
/gpsbabel.rc
/autogen/
/makedoc
/empty
/gbversion.h
/qrc_gpsbabel.cpp
/.vscode/
CMakeCache.txt
CMakeFiles/
CTestTestfile.cmake
Testing
build.ninja
cmake_install.cmake
rules.ninja
2 changes: 1 addition & 1 deletion exif.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ class ExifFormat : public Format
// Return data value interpreted as EXIF_TYPE_LONG.
// This is most useful when the type is EXIF_TYPE_LONG and the count is one,
// which occurs for multiple specific tags where we need the value.
inline uint32_t toLong() const
uint32_t toLong() const
{
return data.at(0).value<uint32_t>();
}
Expand Down
8 changes: 4 additions & 4 deletions garmin.cc
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ waypt_read()
}
}

static int lap_read_nop_cb(int, struct GPS_SWay**)
static int lap_read_nop_cb(int, GPS_SWay**)
{
return 0;
}
Expand Down Expand Up @@ -864,7 +864,7 @@ waypoint_prepare()
extern WaypointList* global_waypoint_list;
int icon;

tx_waylist = (struct GPS_SWay**) xcalloc(n,sizeof(*tx_waylist));
tx_waylist = (GPS_SWay**) xcalloc(n,sizeof(*tx_waylist));

for (i = 0; i < n; i++) {
tx_waylist[i] = sane_GPS_Way_New();
Expand Down Expand Up @@ -1057,7 +1057,7 @@ route_write()
{
int n = 2 * route_waypt_count(); /* Doubled for the islink crap. */

tx_routelist = (struct GPS_SWay**) xcalloc(n,sizeof(GPS_PWay));
tx_routelist = (GPS_SWay**) xcalloc(n,sizeof(GPS_PWay));
cur_tx_routelist_entry = tx_routelist;

for (int i = 0; i < n; i++) {
Expand Down Expand Up @@ -1104,7 +1104,7 @@ track_prepare()
{
int32 n = track_waypt_count() + track_count();

tx_tracklist = (struct GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack));
tx_tracklist = (GPS_STrack**) xcalloc(n, sizeof(GPS_PTrack));
cur_tx_tracklist_entry = tx_tracklist;
for (int i = 0; i < n; i++) {
tx_tracklist[i] = GPS_Track_New();
Expand Down
10 changes: 5 additions & 5 deletions garmin_gpi.h
Original file line number Diff line number Diff line change
Expand Up @@ -293,11 +293,11 @@ class GarminGPIFormat : public Format
static bool compare_wpt_cb(const Waypoint* a, const Waypoint* b);
static char compare_strings(const QString& s1, const QString& s2);
static writer_data_t* wdata_alloc();
static void wdata_free(GarminGPIFormat::writer_data_t* data);
static void wdata_add_wpt(GarminGPIFormat::writer_data_t* data, Waypoint* wpt);
void wdata_check(GarminGPIFormat::writer_data_t* data) const;
int wdata_compute_size(GarminGPIFormat::writer_data_t* data) const;
void wdata_write(const GarminGPIFormat::writer_data_t* data) const;
static void wdata_free(writer_data_t* data);
static void wdata_add_wpt(writer_data_t* data, Waypoint* wpt);
void wdata_check(writer_data_t* data) const;
int wdata_compute_size(writer_data_t* data) const;
void wdata_write(const writer_data_t* data) const;
void write_category(const char* unused, const unsigned char* image, int image_sz) const;
void write_header() const;
void enum_waypt_cb(const Waypoint* ref) const;
Expand Down
2 changes: 1 addition & 1 deletion garmin_txt.cc
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ static constexpr double kGarminUnknownAlt = 1.0e25;
static constexpr char kDefaultDateFormat[] = "dd/mm/yyyy";
static constexpr char kDefaultTimeFormat[] = "HH:mm:ss";

static inline bool is_valid_alt(double alt)
static bool is_valid_alt(double alt)
{
return (alt != unknown_alt) && (alt < kGarminUnknownAlt);
}
Expand Down
4 changes: 2 additions & 2 deletions googletakeout.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,11 @@ static const QList<QString> takeout_month_names{
"AUGUST", "SEPTEMBER", "OCTOBER", "NOVEMBER", "DECEMBER"
};

static inline void takeout_fatal(const QString& message) {
static void takeout_fatal(const QString& message) {
fatal(FatalMsg() << MYNAME << ": " << message);
}

static inline void takeout_warning(const QString& message) {
static void takeout_warning(const QString& message) {
Warning() << MYNAME << ": " << message;
}

Expand Down
2 changes: 1 addition & 1 deletion igc.cc
Original file line number Diff line number Diff line change
Expand Up @@ -467,7 +467,7 @@ void IgcFormat::read()
int len = end - begin + 1;
QString name = extension_definition.mid(4,3);
igc_ext_type_t ext = get_ext_type(ext_type);
if (ext != IgcFormat::igc_ext_type_t::ext_rec_unknown) {
if (ext != igc_ext_type_t::ext_rec_unknown) {
int factor = get_ext_factor(ext);
ext_types_list.append(std::make_tuple(name, ext, begin, len, factor));
supported_extensions.append(name);
Expand Down
44 changes: 22 additions & 22 deletions igc.h
Original file line number Diff line number Diff line change
Expand Up @@ -131,17 +131,17 @@ class IgcFormat : public Format
rec_bad = 1, // Bad record
};

const QHash<QString, IgcFormat::igc_ext_type_t> igc_extension_map{
{"ENL", IgcFormat::igc_ext_type_t::ext_rec_enl},
{"TAS", IgcFormat::igc_ext_type_t::ext_rec_tas},
{"VAT", IgcFormat::igc_ext_type_t::ext_rec_vat},
{"OAT", IgcFormat::igc_ext_type_t::ext_rec_oat},
{"TRT", IgcFormat::igc_ext_type_t::ext_rec_trt},
{"GSP", IgcFormat::igc_ext_type_t::ext_rec_gsp},
{"FXA", IgcFormat::igc_ext_type_t::ext_rec_fxa},
{"SIU", IgcFormat::igc_ext_type_t::ext_rec_siu},
{"ACZ", IgcFormat::igc_ext_type_t::ext_rec_acz},
{"GFO", IgcFormat::igc_ext_type_t::ext_rec_gfo},
const QHash<QString, igc_ext_type_t> igc_extension_map{
{"ENL", igc_ext_type_t::ext_rec_enl},
{"TAS", igc_ext_type_t::ext_rec_tas},
{"VAT", igc_ext_type_t::ext_rec_vat},
{"OAT", igc_ext_type_t::ext_rec_oat},
{"TRT", igc_ext_type_t::ext_rec_trt},
{"GSP", igc_ext_type_t::ext_rec_gsp},
{"FXA", igc_ext_type_t::ext_rec_fxa},
{"SIU", igc_ext_type_t::ext_rec_siu},
{"ACZ", igc_ext_type_t::ext_rec_acz},
{"GFO", igc_ext_type_t::ext_rec_gfo},
};

// Will return zero if no match
Expand All @@ -161,38 +161,38 @@ class IgcFormat : public Format
* A factor can never be zero, so this looks good to me.
* Be careful.
*/
int get_ext_factor(IgcFormat::igc_ext_type_t type) const
int get_ext_factor(igc_ext_type_t type) const
{
int ret = 0;
switch (type) {
case IgcFormat::igc_ext_type_t::ext_rec_enl:
case igc_ext_type_t::ext_rec_enl:
ret = 1;
break;
case IgcFormat::igc_ext_type_t::ext_rec_tas:
case igc_ext_type_t::ext_rec_tas:
ret = 100;
break;
case IgcFormat::igc_ext_type_t::ext_rec_vat:
case igc_ext_type_t::ext_rec_vat:
ret = 10;
break;
case IgcFormat::igc_ext_type_t::ext_rec_oat:
case igc_ext_type_t::ext_rec_oat:
ret = 10;
break;
case IgcFormat::igc_ext_type_t::ext_rec_trt:
case igc_ext_type_t::ext_rec_trt:
ret = 1;
break;
case IgcFormat::igc_ext_type_t::ext_rec_gsp:
case igc_ext_type_t::ext_rec_gsp:
ret = 100;
break;
case IgcFormat::igc_ext_type_t::ext_rec_fxa:
case igc_ext_type_t::ext_rec_fxa:
ret = 1;
break;
case IgcFormat::igc_ext_type_t::ext_rec_siu:
case igc_ext_type_t::ext_rec_siu:
ret = 1;
break;
case IgcFormat::igc_ext_type_t::ext_rec_acz:
case igc_ext_type_t::ext_rec_acz:
ret = 10;
break;
case IgcFormat::igc_ext_type_t::ext_rec_gfo:
case igc_ext_type_t::ext_rec_gfo:
ret = 1;
break;
default:
Expand Down
8 changes: 4 additions & 4 deletions jeeps/gps.h
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ typedef struct GPS_SCourse_Limits {
} GPS_OCourse_Limits, *GPS_PCourse_Limits;


typedef int (*pcb_fn)(int, struct GPS_SWay**);
typedef int (*pcb_fn)(int, GPS_SWay**);

#include "jeeps/gpsdevice.h"
#include "jeeps/gpssend.h"
Expand All @@ -270,9 +270,9 @@ extern char gps_save_string[GPS_ARB_LEN];
extern int gps_is_usb;
extern int gps_baud_rate;

extern struct COMMANDDATA COMMAND_ID[2];
extern struct LINKDATA LINK_ID[3];
extern struct GPS_MODEL_PROTOCOL GPS_MP[];
extern COMMANDDATA COMMAND_ID[2];
extern LINKDATA LINK_ID[3];
extern GPS_MODEL_PROTOCOL GPS_MP[];

extern const char* gps_marine_sym[];
extern const char* gps_land_sym[];
Expand Down
2 changes: 1 addition & 1 deletion jeeps/gpsapp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7571,7 +7571,7 @@ void GPS_Prepare_Track_For_Device(GPS_PTrack** trk, int32* n)
trkpt->distance_populated = 0;
trkpt->heartrate = 0;
trkpt->cadence = 0xff;
*trk = (struct GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack));
*trk = (GPS_STrack**) xrealloc(*trk, (*n+1) * sizeof(GPS_PTrack));
memmove(&(*trk)[i+1], &(*trk)[i], (*n-i) * sizeof(GPS_PTrack));
(*trk)[i] = trkpt;
i++;
Expand Down
18 changes: 9 additions & 9 deletions jeeps/gpscom.cc
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way, pcb_fn cb)
** @return [int32] success
************************************************************************/

int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(struct GPS_SWay**))
int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**))
{
int32 ret=0;

Expand Down Expand Up @@ -1189,7 +1189,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
}

/* Create & append course */
crs = (struct GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse));
crs = (GPS_SCourse**)xrealloc(crs, (n_crs+1) * sizeof(GPS_PCourse));
crs[n_crs] = GPS_Course_New();
if (!crs[n_crs]) {
if (clp) xfree(clp);
Expand All @@ -1203,7 +1203,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
crs[n_crs]->track_index = Unique_Track_Index(crs, n_crs);

/* Create & append new lap */
clp = (struct GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap));
clp = (GPS_SCourse_Lap**) xrealloc(clp, (n_clp+1) * sizeof(GPS_PCourse_Lap));
clp[n_clp] = GPS_Course_Lap_New();
if (!clp[n_clp]) {
if (clp) xfree(clp);
Expand All @@ -1218,7 +1218,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
}

/* Append new track points */
ctk = (struct GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack));
ctk = (GPS_STrack**) xrealloc(ctk, (n_ctk+n_trk) * sizeof(GPS_PTrack));
first_new_ctk = n_ctk;
for (i=0; i<n_trk; i++) {
if (trk[i]->ishdr && (i>=n_trk || trk[i+1]->ishdr)) {
Expand All @@ -1245,7 +1245,7 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
/* Convert waypoints to course points by searching closest track point &
* append
*/
cpt = (struct GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point));
cpt = (GPS_SCourse_Point**) xrealloc(cpt, (n_cpt+n_wpt) * sizeof(GPS_PCourse_Point));
for (i=0; i<n_wpt; i++) {
double dist, min_dist = DBL_MAX;
uint32 min_dist_idx = 0, trk_idx = 0, min_dist_trk_idx = 0;
Expand Down Expand Up @@ -1314,22 +1314,22 @@ int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32
}

/*Stubs for unimplemented stuff*/
int32 GPS_Command_Get_Workout(const char* /* port */, void** /* lap */, int (* /* cb */)(int, struct GPS_SWay**))
int32 GPS_Command_Get_Workout(const char* /* port */, void** /* lap */, int (* /* cb */)(int, GPS_SWay**))
{
return 0;
}

int32 GPS_Command_Get_Fitness_User_Profile(const char* /* port */, void** /* lap */, int (* /* cb */)(int, struct GPS_SWay**))
int32 GPS_Command_Get_Fitness_User_Profile(const char* /* port */, void** /* lap */, int (* /* cb */)(int, GPS_SWay**))
{
return 0;
}

int32 GPS_Command_Get_Workout_Limits(const char* /* port */, void** /* lap */, int (* /* cb */)(int, struct GPS_SWay**))
int32 GPS_Command_Get_Workout_Limits(const char* /* port */, void** /* lap */, int (* /* cb */)(int, GPS_SWay**))
{
return 0;
}

int32 GPS_Command_Get_Course_Limits(const char* /* port */, void** /* lap */, int (* /* cb */)(int, struct GPS_SWay**))
int32 GPS_Command_Get_Course_Limits(const char* /* port */, void** /* lap */, int (* /* cb */)(int, GPS_SWay**))
{
return 0;
}
16 changes: 8 additions & 8 deletions jeeps/gpscom.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,28 +20,28 @@
int32 GPS_Command_Get_Almanac(const char* port, GPS_PAlmanac** alm);
int32 GPS_Command_Send_Almanac(const char* port, GPS_PAlmanac* alm, int32 n);

int32 GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Track(const char* port, GPS_PTrack** trk, int (*cb)(int, GPS_SWay**));
int32 GPS_Command_Send_Track(const char* port, GPS_PTrack* trk, int32 n, int eraset);

int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way,int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(struct GPS_SWay**));
int32 GPS_Command_Get_Waypoint(const char* port, GPS_PWay** way,int (*cb)(int, GPS_SWay**));
int32 GPS_Command_Send_Waypoint(const char* port, GPS_PWay* way, int32 n, int (*cb)(GPS_SWay**));

int32 GPS_Command_Get_Proximity(const char* port, GPS_PWay** way);
int32 GPS_Command_Send_Proximity(const char* port, GPS_PWay* way, int32 n);

int32 GPS_Command_Get_Route(const char* port, GPS_PWay** way);
int32 GPS_Command_Send_Route(const char* port, GPS_PWay* way, int32 n);

int32 GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Lap(const char* port, GPS_PLap** lap, int (*cb)(int, GPS_SWay**));

int32 GPS_Command_Send_Course(const char* port, GPS_PCourse* crs, GPS_PCourse_Lap* clp,
GPS_PTrack* trk, GPS_PCourse_Point* cpt,
int32 n_crs, int32 n_clp, int32 n_trk, int32 n_cpt);
int32 GPS_Command_Send_Track_As_Course(const char* port, GPS_PTrack* trk, int32 n_trk,
GPS_PWay* wpt, int32 n_wpt, int eraset);

int32 GPS_Command_Get_Workout(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, struct GPS_SWay**));
int32 GPS_Command_Get_Workout(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
int32 GPS_Command_Get_Fitness_User_Profile(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
int32 GPS_Command_Get_Workout_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
int32 GPS_Command_Get_Course_Limits(const char* port, void** lap, int (*cb)(int, GPS_SWay**));
#endif
Loading

0 comments on commit 2ff93fa

Please sign in to comment.