From 92d3ae4029c7de91ca3fdca7f70de2c69dd999cb Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sat, 4 May 2024 18:53:41 +0200 Subject: [PATCH] general: remove (void) function parameter declarations To my understanding, declaring empty parameter lists using "(void)" is an artifact from the bad old K&R times, when functions were declared without(!) parameters. Which in hindsight was an absolute recipe for disaster. So for backwards compatibility, functions without parameters had to be declared using "(void)" as "()" could also mean "any function". That was 40 years ago. Meanwhile, C++ introduced references, which made it a necessity to declare the function parameters. So "(void)" is redundant and inconsistent in C++ code and just makes no sense. Remove it. Signed-off-by: Berthold Stoeger --- core/android.cpp | 10 +++++----- core/dive.cpp | 2 +- core/dive.h | 8 ++++---- core/eventtype.h | 2 +- core/filterpreset.cpp | 2 +- core/filterpreset.h | 2 +- core/git-access.h | 2 +- core/ios.cpp | 10 +++++----- core/load-git.cpp | 2 +- core/macos.cpp | 10 +++++----- core/membuffer.cpp | 2 +- core/parse-xml.cpp | 4 ++-- core/parse.h | 4 ++-- core/pref.cpp | 2 +- core/pref.h | 2 +- core/qt-ble.cpp | 2 +- core/qt-ble.h | 2 +- core/selection.cpp | 2 +- core/selection.h | 10 +++++----- core/serial_ftdi.cpp | 2 +- core/subsurfacestartup.cpp | 2 +- core/subsurfacestartup.h | 8 ++++---- core/trip.cpp | 4 ++-- core/trip.h | 4 ++-- core/units.h | 2 +- core/unix.cpp | 10 +++++----- core/version.cpp | 4 ++-- core/version.h | 4 ++-- core/webservice.h | 2 +- core/windows.cpp | 10 +++++----- desktop-widgets/mainwindow.cpp | 4 ++-- desktop-widgets/printdialog.cpp | 6 +++--- 32 files changed, 71 insertions(+), 71 deletions(-) diff --git a/core/android.cpp b/core/android.cpp index fef58a48c..3a305dff6 100644 --- a/core/android.cpp +++ b/core/android.cpp @@ -46,7 +46,7 @@ const char *system_divelist_default_font = android_system_divelist_default_font; double system_divelist_default_font_size = -1; int get_usb_fd(uint16_t idVendor, uint16_t idProduct); -void subsurface_OS_pref_setup(void) +void subsurface_OS_pref_setup() { } @@ -56,13 +56,13 @@ bool subsurface_ignore_font(const char *font) return false; } -const char *system_default_directory(void) +const char *system_default_directory() { static const std::string path = system_default_path(); return path.c_str(); } -const char *system_default_filename(void) +const char *system_default_filename() { static const std::string fn = make_default_filename(); return fn.c_str(); @@ -235,12 +235,12 @@ int subsurface_zip_close(struct zip *zip) } /* win32 console */ -void subsurface_console_init(void) +void subsurface_console_init() { /* NOP */ } -void subsurface_console_exit(void) +void subsurface_console_exit() { /* NOP */ } diff --git a/core/dive.cpp b/core/dive.cpp index 80a441dfb..343e90bd4 100644 --- a/core/dive.cpp +++ b/core/dive.cpp @@ -163,7 +163,7 @@ int dive_getUniqID() return maxId; } -struct dive *alloc_dive(void) +struct dive *alloc_dive() { struct dive *dive; diff --git a/core/dive.h b/core/dive.h index 1c8696110..492e67fcf 100644 --- a/core/dive.h +++ b/core/dive.h @@ -158,11 +158,11 @@ extern int save_dive_sites_logic(const char *filename, const struct dive_site *s struct membuffer; extern void save_one_dive_to_mb(struct membuffer *b, struct dive *dive, bool anonymize); -extern void subsurface_console_init(void); -extern void subsurface_console_exit(void); -extern bool subsurface_user_is_root(void); +extern void subsurface_console_init(); +extern void subsurface_console_exit(); +extern bool subsurface_user_is_root(); -extern struct dive *alloc_dive(void); +extern struct dive *alloc_dive(); extern void free_dive(struct dive *); extern void record_dive_to_table(struct dive *dive, struct dive_table *table); extern void clear_dive(struct dive *dive); diff --git a/core/eventtype.h b/core/eventtype.h index 8f0ecd28e..94fad72db 100644 --- a/core/eventtype.h +++ b/core/eventtype.h @@ -6,7 +6,7 @@ #include #include -extern void clear_event_types(void); +extern void clear_event_types(); extern void remember_event_type(const struct event *ev); extern bool is_event_type_hidden(const struct event *ev); extern void hide_event_type(const struct event *ev); diff --git a/core/filterpreset.cpp b/core/filterpreset.cpp index 518b2b264..2366e88e2 100644 --- a/core/filterpreset.cpp +++ b/core/filterpreset.cpp @@ -9,7 +9,7 @@ static filter_preset_table &global_table() return *divelog.filter_presets; } -int filter_presets_count(void) +int filter_presets_count() { return (int)global_table().size(); } diff --git a/core/filterpreset.h b/core/filterpreset.h index 807a1c48c..5485f5bde 100644 --- a/core/filterpreset.h +++ b/core/filterpreset.h @@ -30,7 +30,7 @@ struct filter_preset_table : public std::vector }; // The C IO code accesses the filter presets via integer indices. -extern int filter_presets_count(void); +extern int filter_presets_count(); extern const char *filter_preset_fulltext_mode(int preset); // string mode of fulltext query. ownership is *not* passed to caller. extern int filter_preset_constraint_count(int preset); // number of constraints in the filter preset. extern const struct filter_constraint *filter_preset_constraint(int preset, int constraint); // get constraint. ownership is *not* passed to caller. diff --git a/core/git-access.h b/core/git-access.h index ed9e4ed5e..e596e8b82 100644 --- a/core/git-access.h +++ b/core/git-access.h @@ -22,7 +22,7 @@ enum remote_transport { RT_LOCAL, RT_HTTPS, RT_SSH, RT_OTHER }; extern bool git_local_only; extern bool git_remote_sync_successful; -extern void clear_git_id(void); +extern void clear_git_id(); extern void set_git_id(const struct git_oid *); void set_git_update_cb(int(*)(const char *)); int git_storage_update_progress(const char *text); diff --git a/core/ios.cpp b/core/ios.cpp index 15f1c4501..ecb81777f 100644 --- a/core/ios.cpp +++ b/core/ios.cpp @@ -36,7 +36,7 @@ const char mac_system_divelist_default_font[] = "Arial"; const char *system_divelist_default_font = mac_system_divelist_default_font; double system_divelist_default_font_size = -1.0; -void subsurface_OS_pref_setup(void) +void subsurface_OS_pref_setup() { // nothing } @@ -47,13 +47,13 @@ bool subsurface_ignore_font(const char*) return false; } -const char *system_default_directory(void) +const char *system_default_directory() { static const std::string path = system_default_path(); return path.c_str(); } -const char *system_default_filename(void) +const char *system_default_filename() { static const std::string fn = make_default_filename(); return fn.c_str(); @@ -107,12 +107,12 @@ int subsurface_zip_close(struct zip *zip) } /* win32 console */ -void subsurface_console_init(void) +void subsurface_console_init() { /* NOP */ } -void subsurface_console_exit(void) +void subsurface_console_exit() { /* NOP */ } diff --git a/core/load-git.cpp b/core/load-git.cpp index 3157a28b8..cb488e2d5 100644 --- a/core/load-git.cpp +++ b/core/load-git.cpp @@ -1846,7 +1846,7 @@ static int load_dives_from_tree(git_repository *repo, git_tree *tree, struct git return 0; } -void clear_git_id(void) +void clear_git_id() { saved_git_id.clear(); } diff --git a/core/macos.cpp b/core/macos.cpp index 4c7c1426e..50f32448e 100644 --- a/core/macos.cpp +++ b/core/macos.cpp @@ -52,7 +52,7 @@ const char mac_system_divelist_default_font[] = "Arial"; const char *system_divelist_default_font = mac_system_divelist_default_font; double system_divelist_default_font_size = -1.0; -void subsurface_OS_pref_setup(void) +void subsurface_OS_pref_setup() { // nothing } @@ -63,13 +63,13 @@ bool subsurface_ignore_font(const char *) return false; } -const char *system_default_directory(void) +const char *system_default_directory() { static const std::string path = system_default_path(); return path.c_str(); } -const char *system_default_filename(void) +const char *system_default_filename() { static const std::string fn = make_default_filename(); return fn.c_str(); @@ -183,12 +183,12 @@ int subsurface_zip_close(struct zip *zip) } /* win32 console */ -void subsurface_console_init(void) +void subsurface_console_init() { /* NOP */ } -void subsurface_console_exit(void) +void subsurface_console_exit() { /* NOP */ } diff --git a/core/membuffer.cpp b/core/membuffer.cpp index 2b8b7c8bc..86872e6af 100644 --- a/core/membuffer.cpp +++ b/core/membuffer.cpp @@ -63,7 +63,7 @@ void strip_mb(struct membuffer *b) * interface very complex, we'll just die. It won't happen * unless you're running on a potato. */ -static void oom(void) +static void oom() { fprintf(stderr, "Out of memory\n"); exit(1); diff --git a/core/parse-xml.cpp b/core/parse-xml.cpp index b623e9ddd..17c89168c 100644 --- a/core/parse-xml.cpp +++ b/core/parse-xml.cpp @@ -2274,12 +2274,12 @@ int parse_dlf_buffer(unsigned char *buffer, size_t size, struct divelog *log) } -void parse_xml_init(void) +void parse_xml_init() { LIBXML_TEST_VERSION } -void parse_xml_exit(void) +void parse_xml_exit() { xmlCleanupParser(); } diff --git a/core/parse.h b/core/parse.h index f9152c8b0..ac905214e 100644 --- a/core/parse.h +++ b/core/parse.h @@ -148,9 +148,9 @@ void nonmatch(const char *type, const char *name, char *buffer); int atoi_n(char *ptr, unsigned int len); void utf8_string(const char *buffer, char **res); -void parse_xml_init(void); +void parse_xml_init(); int parse_xml_buffer(const char *url, const char *buf, int size, struct divelog *log, const struct xml_params *params); -void parse_xml_exit(void); +void parse_xml_exit(); int parse_dm4_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct divelog *log); int parse_dm5_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct divelog *log); int parse_seac_buffer(sqlite3 *handle, const char *url, const char *buf, int size, struct divelog *log); diff --git a/core/pref.cpp b/core/pref.cpp index 2a04ba7ff..4bce25ed8 100644 --- a/core/pref.cpp +++ b/core/pref.cpp @@ -149,7 +149,7 @@ void copy_prefs(struct preferences *src, struct preferences *dest) * These are not real leaks but they plug the holes found by eg. * valgrind so you can find the real leaks. */ -void free_prefs(void) +void free_prefs() { // nop } diff --git a/core/pref.h b/core/pref.h index 214fcd551..85d78afcf 100644 --- a/core/pref.h +++ b/core/pref.h @@ -214,7 +214,7 @@ extern struct preferences prefs, default_prefs, git_prefs; extern const char *system_divelist_default_font; extern double system_divelist_default_font_size; -extern const char *system_default_directory(void); +extern const char *system_default_directory(); extern const char *system_default_filename(); extern bool subsurface_ignore_font(const char *font); extern void subsurface_OS_pref_setup(); diff --git a/core/qt-ble.cpp b/core/qt-ble.cpp index 2df255576..fdbef3bce 100644 --- a/core/qt-ble.cpp +++ b/core/qt-ble.cpp @@ -414,7 +414,7 @@ dc_status_t BLEObject::read(void *data, size_t size, size_t *actual) // // That's wrong, but works for the simple case. // -dc_status_t BLEObject::select_preferred_service(void) +dc_status_t BLEObject::select_preferred_service() { // Wait for each service to finish discovering for (const QLowEnergyService *s: services) { diff --git a/core/qt-ble.h b/core/qt-ble.h index d99dbadb5..f4750a9ae 100644 --- a/core/qt-ble.h +++ b/core/qt-ble.h @@ -32,7 +32,7 @@ public: inline QLowEnergyService *preferredService() { return preferred; } inline int descriptorWritten() { return desc_written; } - dc_status_t select_preferred_service(void); + dc_status_t select_preferred_service(); public slots: void addService(const QBluetoothUuid &newService); diff --git a/core/selection.cpp b/core/selection.cpp index 52178cb2e..91d2e58b0 100644 --- a/core/selection.cpp +++ b/core/selection.cpp @@ -63,7 +63,7 @@ bool consecutive_selected() } #if DEBUG_SELECTION_TRACKING -void dump_selection(void) +void dump_selection() { int i; struct dive *dive; diff --git a/core/selection.h b/core/selection.h index d21ff0a98..a1e92e8a4 100644 --- a/core/selection.h +++ b/core/selection.h @@ -12,18 +12,18 @@ struct dive; extern int amount_selected; extern struct dive *current_dive; -extern struct dive *first_selected_dive(void); -extern struct dive *last_selected_dive(void); -extern bool consecutive_selected(void); +extern struct dive *first_selected_dive(); +extern struct dive *last_selected_dive(); +extern bool consecutive_selected(); extern void select_newest_visible_dive(); extern void select_single_dive(struct dive *d); // wrapper for setSelection() with a single dive. NULL clears the selection. extern void select_trip(struct dive_trip *trip); extern void deselect_trip(struct dive_trip *trip); extern struct dive_trip *single_selected_trip(); // returns trip if exactly one trip is selected, NULL otherwise. -extern void clear_selection(void); +extern void clear_selection(); #if DEBUG_SELECTION_TRACKING -extern void dump_selection(void); +extern void dump_selection(); #endif // Reset the selection to the dives of the "selection" vector and send the appropriate signals. diff --git a/core/serial_ftdi.cpp b/core/serial_ftdi.cpp index daaecadfb..0be317f7f 100644 --- a/core/serial_ftdi.cpp +++ b/core/serial_ftdi.cpp @@ -106,7 +106,7 @@ static dc_status_t serial_ftdi_get_transmitted (ftdi_serial_t *device) /* * Get an msec value on some random base */ -static unsigned int serial_ftdi_get_msec(void) +static unsigned int serial_ftdi_get_msec() { #ifdef _WIN32 return GetTickCount(); diff --git a/core/subsurfacestartup.cpp b/core/subsurfacestartup.cpp index 86d600109..9cfd9f7f9 100644 --- a/core/subsurfacestartup.cpp +++ b/core/subsurfacestartup.cpp @@ -191,7 +191,7 @@ void parse_argument(const char *arg) * I guess Burma and Liberia should trigger this too. I'm too * lazy to look up the territory names, though. */ -void setup_system_prefs(void) +void setup_system_prefs() { const char *env; diff --git a/core/subsurfacestartup.h b/core/subsurfacestartup.h index ddb18b53f..1180ad2a5 100644 --- a/core/subsurfacestartup.h +++ b/core/subsurfacestartup.h @@ -5,11 +5,11 @@ extern bool imported; extern int quit, force_root, ignore_bt; -void setup_system_prefs(void); +void setup_system_prefs(); void parse_argument(const char *arg); -void free_prefs(void); -void print_files(void); -void print_version(void); +void free_prefs(); +void print_files(); +void print_version(); extern char *settings_suffix; diff --git a/core/trip.cpp b/core/trip.cpp index b83928502..df66f211a 100644 --- a/core/trip.cpp +++ b/core/trip.cpp @@ -10,7 +10,7 @@ #include "core/errorhelper.h" #ifdef DEBUG_TRIP -void dump_trip_list(void) +void dump_trip_list() { dive_trip_t *trip; int i = 0; @@ -126,7 +126,7 @@ void remove_dive_from_trip(struct dive *dive, struct trip_table *trip_table_arg) delete_trip(trip, trip_table_arg); } -dive_trip_t *alloc_trip(void) +dive_trip_t *alloc_trip() { dive_trip_t *res = (dive_trip_t *)calloc(1, sizeof(dive_trip_t)); res->id = dive_getUniqID(); diff --git a/core/trip.h b/core/trip.h index cb4a8da0f..df15ee770 100644 --- a/core/trip.h +++ b/core/trip.h @@ -37,7 +37,7 @@ extern bool trip_less_than(const struct dive_trip *a, const struct dive_trip *b) extern int comp_trips(const struct dive_trip *a, const struct dive_trip *b); extern void sort_trip_table(struct trip_table *table); -extern dive_trip_t *alloc_trip(void); +extern dive_trip_t *alloc_trip(); extern dive_trip_t *create_trip_from_dive(struct dive *dive); extern dive_trip_t *get_dives_to_autogroup(struct dive_table *table, int start, int *from, int *to, bool *allocated); extern dive_trip_t *get_trip_for_new_dive(struct dive *new_dive, bool *allocated); @@ -53,7 +53,7 @@ void move_trip_table(struct trip_table *src, struct trip_table *dst); void clear_trip_table(struct trip_table *table); #ifdef DEBUG_TRIP -extern void dump_trip_list(void); +extern void dump_trip_list(); #endif /* Make pointers to dive_trip and trip_table "Qt metatypes" so that they can be diff --git a/core/units.h b/core/units.h index c1c68cc59..5465e07eb 100644 --- a/core/units.h +++ b/core/units.h @@ -325,7 +325,7 @@ struct units { extern const struct units SI_units, IMPERIAL_units; -extern const struct units *get_units(void); +extern const struct units *get_units(); extern int get_pressure_units(int mb, const char **units); extern double get_depth_units(int mm, int *frac, const char **units); diff --git a/core/unix.cpp b/core/unix.cpp index dcae486a3..9692fd136 100644 --- a/core/unix.cpp +++ b/core/unix.cpp @@ -40,7 +40,7 @@ const char unix_system_divelist_default_font[] = "Sans"; const char *system_divelist_default_font = unix_system_divelist_default_font; double system_divelist_default_font_size = -1.0; -void subsurface_OS_pref_setup(void) +void subsurface_OS_pref_setup() { // nothing } @@ -51,13 +51,13 @@ bool subsurface_ignore_font(const char *) return false; } -const char *system_default_directory(void) +const char *system_default_directory() { static const std::string path = system_default_path(); return path.c_str(); } -const char *system_default_filename(void) +const char *system_default_filename() { static const std::string fn = make_default_filename(); return fn.c_str(); @@ -187,12 +187,12 @@ int subsurface_zip_close(struct zip *zip) } /* win32 console */ -void subsurface_console_init(void) +void subsurface_console_init() { /* NOP */ } -void subsurface_console_exit(void) +void subsurface_console_exit() { /* NOP */ } diff --git a/core/version.cpp b/core/version.cpp index 811e763b8..09c23d33b 100644 --- a/core/version.cpp +++ b/core/version.cpp @@ -2,12 +2,12 @@ #include "ssrf-version.h" // let's leave the two redundant functions in case we change our minds on git SHAs -const char *subsurface_git_version(void) +const char *subsurface_git_version() { return CANONICAL_VERSION_STRING_4; } -const char *subsurface_canonical_version(void) +const char *subsurface_canonical_version() { return CANONICAL_VERSION_STRING; } diff --git a/core/version.h b/core/version.h index 148f2d559..37a7d4df3 100644 --- a/core/version.h +++ b/core/version.h @@ -1,7 +1,7 @@ #ifndef VERSION_H #define VERSION_H -const char *subsurface_git_version(void); -const char *subsurface_canonical_version(void); +const char *subsurface_git_version(); +const char *subsurface_canonical_version(); #endif diff --git a/core/webservice.h b/core/webservice.h index 4831072dd..bdb9ddfbf 100644 --- a/core/webservice.h +++ b/core/webservice.h @@ -2,7 +2,7 @@ #ifndef WEBSERVICE_H #define WEBSERVICE_H -//extern void webservice_download_dialog(void); +//extern void webservice_download_dialog(); //extern bool webservice_request_user_xml(const gchar *, gchar **, unsigned int *, unsigned int *); extern int divelogde_upload(char *fn, char **error); extern unsigned int download_dialog_parse_response(char *xmldata, unsigned int len); diff --git a/core/windows.cpp b/core/windows.cpp index c244cfc5a..ae8e64b76 100644 --- a/core/windows.cpp +++ b/core/windows.cpp @@ -105,7 +105,7 @@ const char current_system_divelist_default_font[] = "Segoe UI"; const char *system_divelist_default_font = non_standard_system_divelist_default_font; double system_divelist_default_font_size = -1; -void subsurface_OS_pref_setup(void) +void subsurface_OS_pref_setup() { if (isWin7Or8()) system_divelist_default_font = current_system_divelist_default_font; @@ -124,13 +124,13 @@ bool subsurface_ignore_font(const char *font) /* '\' not included at the end. */ -const char *system_default_directory(void) +const char *system_default_directory() { static std::string path = utf16_to_utf8(system_default_path()); return path.c_str(); } -const char *system_default_filename(void) +const char *system_default_filename() { static std::string path = utf16_to_utf8(make_default_filename()); return path.c_str(); @@ -373,7 +373,7 @@ static struct { } console_desc; #endif -void subsurface_console_init(void) +void subsurface_console_init() { /* if this is a console app already, do nothing */ #ifndef WIN32_CONSOLE_APP @@ -404,7 +404,7 @@ void subsurface_console_init(void) #endif } -void subsurface_console_exit(void) +void subsurface_console_exit() { #ifndef WIN32_CONSOLE_APP /* close handles */ diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index d5587c0f4..65a331584 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -1184,7 +1184,7 @@ void MainWindow::recentFileTriggered(bool) loadFiles(std::vector { filename.toStdString() }); } -int MainWindow::file_save_as(void) +int MainWindow::file_save_as() { QString filename; std::string default_filename = existing_filename; @@ -1232,7 +1232,7 @@ int MainWindow::file_save_as(void) return 0; } -int MainWindow::file_save(void) +int MainWindow::file_save() { const char *current_default; bool is_cloud = false; diff --git a/desktop-widgets/printdialog.cpp b/desktop-widgets/printdialog.cpp index 8abaac4a2..885d8d321 100644 --- a/desktop-widgets/printdialog.cpp +++ b/desktop-widgets/printdialog.cpp @@ -184,7 +184,7 @@ void PrintDialog::createPrinterObj() } } -void PrintDialog::previewClicked(void) +void PrintDialog::previewClicked() { createPrinterObj(); QPrintPreviewDialog previewDialog(qprinter, this, Qt::Window @@ -194,7 +194,7 @@ void PrintDialog::previewClicked(void) previewDialog.exec(); } -void PrintDialog::exportHtmlClicked(void) +void PrintDialog::exportHtmlClicked() { createPrinterObj(); QString saveFileName = printOptions.p_template; @@ -212,7 +212,7 @@ void PrintDialog::exportHtmlClicked(void) } } -void PrintDialog::printClicked(void) +void PrintDialog::printClicked() { createPrinterObj(); QPrintDialog printDialog(qprinter, this);