From fcc52e83de03b2a6932f37d4148fbd79f6c80523 Mon Sep 17 00:00:00 2001 From: gullradriel <3157857+gullradriel@users.noreply.github.com> Date: Mon, 14 Oct 2024 15:50:04 +0200 Subject: [PATCH] enforce #ifndef __HEADER_H instead of #pragma once, for code consitency and better portability (#2296) --- firmware/application/apps/ui_external_module_view.hpp | 5 ++++- .../application/external/spainter/ui_spectrum_painter.hpp | 5 ++++- .../external/spainter/ui_spectrum_painter_image.hpp | 5 ++++- .../external/spainter/ui_spectrum_painter_text.hpp | 5 ++++- firmware/application/io.hpp | 5 ++++- firmware/application/io_convert.hpp | 5 ++++- firmware/application/io_file.hpp | 5 ++++- firmware/application/io_wave.hpp | 5 ++++- firmware/application/portapack.hpp | 5 ++++- firmware/application/usb_serial.hpp | 5 ++++- firmware/application/usb_serial_cdc.h | 5 ++++- firmware/application/usb_serial_descriptor.h | 5 ++++- firmware/application/usb_serial_device_to_host.h | 5 ++++- firmware/application/usb_serial_endpoints.h | 5 ++++- firmware/application/usb_serial_event.hpp | 5 ++++- firmware/application/usb_serial_host_to_device.hpp | 5 ++++- firmware/application/usb_serial_shell.hpp | 5 ++++- firmware/baseband/proc_spectrum_painter.hpp | 5 ++++- firmware/common/backlight.hpp | 5 ++++- firmware/common/buffer_exchange.hpp | 5 ++++- firmware/common/i2cdev_ppmod.hpp | 5 ++++- firmware/common/random.hpp | 5 ++++- firmware/test/application/mock_file.hpp | 5 ++++- 23 files changed, 92 insertions(+), 23 deletions(-) diff --git a/firmware/application/apps/ui_external_module_view.hpp b/firmware/application/apps/ui_external_module_view.hpp index 2bc14344..f09cf2f2 100644 --- a/firmware/application/apps/ui_external_module_view.hpp +++ b/firmware/application/apps/ui_external_module_view.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __UI_EXTERNAL_MODULE_VIEW_H +#define __UI_EXTERNAL_MODULE_VIEW_H #include "ui.hpp" #include "ui_widget.hpp" @@ -92,3 +93,5 @@ class ExternalModuleView : public View { }; } // namespace ui + +#endif diff --git a/firmware/application/external/spainter/ui_spectrum_painter.hpp b/firmware/application/external/spainter/ui_spectrum_painter.hpp index af9bd883..63e7e9c9 100644 --- a/firmware/application/external/spainter/ui_spectrum_painter.hpp +++ b/firmware/application/external/spainter/ui_spectrum_painter.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __UI_SPECTRUM_PAINTER_H +#define __UI_SPECTRUM_PAINTER_H #include "ui.hpp" #include "ui_language.hpp" @@ -165,3 +166,5 @@ class SpectrumPainterView : public View { }; } // namespace ui::external_app::spainter + +#endif diff --git a/firmware/application/external/spainter/ui_spectrum_painter_image.hpp b/firmware/application/external/spainter/ui_spectrum_painter_image.hpp index 711e8f27..a9c1bf62 100644 --- a/firmware/application/external/spainter/ui_spectrum_painter_image.hpp +++ b/firmware/application/external/spainter/ui_spectrum_painter_image.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __UI_SPECTRUM_PAINTER_IMAGE_H +#define __UI_SPECTRUM_PAINTER_IMAGE_H #include "ui.hpp" #include "ui_widget.hpp" @@ -64,3 +65,5 @@ class SpectrumInputImageView : public View { }; } // namespace ui::external_app::spainter + +#endif diff --git a/firmware/application/external/spainter/ui_spectrum_painter_text.hpp b/firmware/application/external/spainter/ui_spectrum_painter_text.hpp index 5a3859ce..f31305d2 100644 --- a/firmware/application/external/spainter/ui_spectrum_painter_text.hpp +++ b/firmware/application/external/spainter/ui_spectrum_painter_text.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __UI_SPECTRUM_PAINTER_TEXT_H +#define __UI_SPECTRUM_PAINTER_TEXT_H #include "ui.hpp" #include "ui_widget.hpp" @@ -110,3 +111,5 @@ class SpectrumInputTextView : public View { }; } // namespace ui::external_app::spainter + +#endif diff --git a/firmware/application/io.hpp b/firmware/application/io.hpp index ebbf9c45..fcaad0e9 100644 --- a/firmware/application/io.hpp +++ b/firmware/application/io.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __IO_H +#define __IO_H #include "file.hpp" @@ -38,3 +39,5 @@ class Writer { }; } /* namespace stream */ + +#endif diff --git a/firmware/application/io_convert.hpp b/firmware/application/io_convert.hpp index 78014203..0455444f 100644 --- a/firmware/application/io_convert.hpp +++ b/firmware/application/io_convert.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __IO_CONVERT_H +#define __IO_CONVERT_H #include "io_file.hpp" @@ -77,3 +78,5 @@ class FileConvertWriter : public stream::Writer { File file_{}; uint64_t bytes_written_{0}; }; + +#endif diff --git a/firmware/application/io_file.hpp b/firmware/application/io_file.hpp index 5dffa789..c7988ff4 100644 --- a/firmware/application/io_file.hpp +++ b/firmware/application/io_file.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __IO_FILE_H +#define __IO_FILE_H #include "io.hpp" @@ -71,3 +72,5 @@ class FileWriter : public stream::Writer { }; using RawFileWriter = FileWriter; + +#endif diff --git a/firmware/application/io_wave.hpp b/firmware/application/io_wave.hpp index 0293e5f9..6d32454f 100644 --- a/firmware/application/io_wave.hpp +++ b/firmware/application/io_wave.hpp @@ -20,7 +20,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __IO_WAVE_H +#define __IO_WAVE_H #include "io_file.hpp" @@ -181,3 +182,5 @@ class WAVFileWriter : public FileWriter { Optional update_header(); Optional write_tags(); }; + +#endif diff --git a/firmware/application/portapack.hpp b/firmware/application/portapack.hpp index 62c94d17..6273c7ce 100644 --- a/firmware/application/portapack.hpp +++ b/firmware/application/portapack.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __PORTAPACK_H +#define __PORTAPACK_H #include "portapack_io.hpp" @@ -85,3 +86,5 @@ Backlight* backlight(); extern bool async_tx_enabled; // this is for serial tx things, globally } /* namespace portapack */ + +#endif diff --git a/firmware/application/usb_serial.hpp b/firmware/application/usb_serial.hpp index 59cddd8a..4da8dbeb 100644 --- a/firmware/application/usb_serial.hpp +++ b/firmware/application/usb_serial.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_H +#define __USB_SERIAL_H #include "ch.h" #include "hal.h" @@ -54,3 +55,5 @@ class USBSerial { }; } // namespace portapack + +#endif diff --git a/firmware/application/usb_serial_cdc.h b/firmware/application/usb_serial_cdc.h index ee6f3239..10d844cf 100644 --- a/firmware/application/usb_serial_cdc.h +++ b/firmware/application/usb_serial_cdc.h @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_CDC_H +#define __USB_SERIAL_CDC_H #include "ch.h" #include "hal.h" @@ -44,3 +45,5 @@ usb_request_status_t usb_set_line_coding_request(usb_endpoint_t* const endpoint, #endif void setup_usb_serial_controller(void); + +#endif diff --git a/firmware/application/usb_serial_descriptor.h b/firmware/application/usb_serial_descriptor.h index ebc073b7..5a5d0547 100644 --- a/firmware/application/usb_serial_descriptor.h +++ b/firmware/application/usb_serial_descriptor.h @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_DESCRIPTOR_H +#define __USB_SERIAL_DESCRIPTOR_H #include "ch.h" #include "hal.h" @@ -42,3 +43,5 @@ extern uint8_t* usb_descriptor_strings[]; #define USB_WCID_VENDOR_REQ 0x19 extern uint8_t wcid_string_descriptor[]; extern uint8_t wcid_feature_descriptor[]; + +#endif diff --git a/firmware/application/usb_serial_device_to_host.h b/firmware/application/usb_serial_device_to_host.h index 77f688de..68a2ac1d 100644 --- a/firmware/application/usb_serial_device_to_host.h +++ b/firmware/application/usb_serial_device_to_host.h @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_DEVICE_TO_HOST_H +#define __USB_SERIAL_DEVICE_TO_HOST_H #include "ch.h" #include "hal.h" @@ -56,3 +57,5 @@ size_t fillOBuffer(OutputQueue* oqp, const uint8_t* bp, size_t n); #ifdef __cplusplus } #endif + +#endif diff --git a/firmware/application/usb_serial_endpoints.h b/firmware/application/usb_serial_endpoints.h index 48ebaea2..fd02cf11 100644 --- a/firmware/application/usb_serial_endpoints.h +++ b/firmware/application/usb_serial_endpoints.h @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_ENDPOINTS_H +#define __USB_SERIAL_ENDPOINTS_H #include "ch.h" #include "hal.h" @@ -49,3 +50,5 @@ extern USB_DECLARE_QUEUE(usb_endpoint_bulk_in); extern usb_endpoint_t usb_endpoint_bulk_out; extern USB_DECLARE_QUEUE(usb_endpoint_bulk_out); + +#endif diff --git a/firmware/application/usb_serial_event.hpp b/firmware/application/usb_serial_event.hpp index a3e40afb..6d9d3ae2 100644 --- a/firmware/application/usb_serial_event.hpp +++ b/firmware/application/usb_serial_event.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_EVENT_H +#define __USB_SERIAL_EVENT_H #include "ch.h" #include "hal.h" @@ -32,3 +33,5 @@ void on_channel_closed(void); #ifdef __cplusplus } #endif + +#endif diff --git a/firmware/application/usb_serial_host_to_device.hpp b/firmware/application/usb_serial_host_to_device.hpp index e67f8093..8a0b9d71 100644 --- a/firmware/application/usb_serial_host_to_device.hpp +++ b/firmware/application/usb_serial_host_to_device.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_HOST_TO_DEVICE_H +#define __USB_SERIAL_HOST_TO_DEVICE_H #include "ch.h" #include "hal.h" @@ -31,3 +32,5 @@ void reset_transfer_queues(); void serial_bulk_transfer_complete(void* user_data, unsigned int bytes_transferred); void schedule_host_to_device_transfer(); void complete_host_to_device_transfer(); + +#endif diff --git a/firmware/application/usb_serial_shell.hpp b/firmware/application/usb_serial_shell.hpp index d442f92b..6a049ab2 100644 --- a/firmware/application/usb_serial_shell.hpp +++ b/firmware/application/usb_serial_shell.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __USB_SERIAL_SHELL_H +#define __USB_SERIAL_SHELL_H #include "ch.h" #include "hal.h" @@ -29,3 +30,5 @@ class EventDispatcher; void create_shell(EventDispatcher* evtd); + +#endif diff --git a/firmware/baseband/proc_spectrum_painter.hpp b/firmware/baseband/proc_spectrum_painter.hpp index 438dd595..ad18cc11 100644 --- a/firmware/baseband/proc_spectrum_painter.hpp +++ b/firmware/baseband/proc_spectrum_painter.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __PROC_SPECTRUM_PAINTER_H +#define __PROC_SPECTRUM_PAINTER_H #include "portapack_shared_memory.hpp" #include "baseband_processor.hpp" @@ -46,3 +47,5 @@ class SpectrumPainterProcessor : public BasebandProcessor { return 0; } }; + +#endif diff --git a/firmware/common/backlight.hpp b/firmware/common/backlight.hpp index 703b5c24..6f773229 100644 --- a/firmware/common/backlight.hpp +++ b/firmware/common/backlight.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __BACKLIGHT_H +#define __BACKLIGHT_H #include @@ -118,3 +119,5 @@ class BacklightCAT4004 : public BacklightBase { }; } /* namespace portapack */ + +#endif diff --git a/firmware/common/buffer_exchange.hpp b/firmware/common/buffer_exchange.hpp index b188ba6b..7e4e4411 100644 --- a/firmware/common/buffer_exchange.hpp +++ b/firmware/common/buffer_exchange.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __BUFFER_EXCHANGE_H +#define __BUFFER_EXCHANGE_H #include "ch.h" @@ -110,3 +111,5 @@ class BufferExchange { StreamBuffer* get_prefill(FIFO* fifo); }; + +#endif diff --git a/firmware/common/i2cdev_ppmod.hpp b/firmware/common/i2cdev_ppmod.hpp index bbbba96c..56dc5713 100644 --- a/firmware/common/i2cdev_ppmod.hpp +++ b/firmware/common/i2cdev_ppmod.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __I2CDEV_PPMOD_H +#define __I2CDEV_PPMOD_H #include #include @@ -71,3 +72,5 @@ class I2cDev_PPmod : public I2cDev { }; } /* namespace i2cdev */ + +#endif diff --git a/firmware/common/random.hpp b/firmware/common/random.hpp index 5442fc31..a31583c8 100644 --- a/firmware/common/random.hpp +++ b/firmware/common/random.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __RANDOM_H +#define __RANDOM_H /* Period parameters */ #define N 624 @@ -33,3 +34,5 @@ /* initializes state[N] with a seed */ extern void init_genrand(unsigned long s); extern long genrand_int31(void); + +#endif diff --git a/firmware/test/application/mock_file.hpp b/firmware/test/application/mock_file.hpp index 1dea7743..06b95c2d 100644 --- a/firmware/test/application/mock_file.hpp +++ b/firmware/test/application/mock_file.hpp @@ -19,7 +19,8 @@ * Boston, MA 02110-1301, USA. */ -#pragma once +#ifndef __MOCK_FILE_H +#define __MOCK_FILE_H #include "file.hpp" #include @@ -87,3 +88,5 @@ class MockFile { std::string data_; uint32_t offset_{0}; }; + +#endif