Skip to content

Commit

Permalink
enforce #ifndef __HEADER_H instead of #pragma once, for code consiten…
Browse files Browse the repository at this point in the history
…cy and better portability (#2296)
  • Loading branch information
gullradriel authored Oct 14, 2024
1 parent dcaa02c commit fcc52e8
Show file tree
Hide file tree
Showing 23 changed files with 92 additions and 23 deletions.
5 changes: 4 additions & 1 deletion firmware/application/apps/ui_external_module_view.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -92,3 +93,5 @@ class ExternalModuleView : public View {
};

} // namespace ui

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -165,3 +166,5 @@ class SpectrumPainterView : public View {
};

} // namespace ui::external_app::spainter

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -64,3 +65,5 @@ class SpectrumInputImageView : public View {
};

} // namespace ui::external_app::spainter

#endif
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -110,3 +111,5 @@ class SpectrumInputTextView : public View {
};

} // namespace ui::external_app::spainter

#endif
5 changes: 4 additions & 1 deletion firmware/application/io.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __IO_H
#define __IO_H

#include "file.hpp"

Expand All @@ -38,3 +39,5 @@ class Writer {
};

} /* namespace stream */

#endif
5 changes: 4 additions & 1 deletion firmware/application/io_convert.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __IO_CONVERT_H
#define __IO_CONVERT_H

#include "io_file.hpp"

Expand Down Expand Up @@ -77,3 +78,5 @@ class FileConvertWriter : public stream::Writer {
File file_{};
uint64_t bytes_written_{0};
};

#endif
5 changes: 4 additions & 1 deletion firmware/application/io_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __IO_FILE_H
#define __IO_FILE_H

#include "io.hpp"

Expand Down Expand Up @@ -71,3 +72,5 @@ class FileWriter : public stream::Writer {
};

using RawFileWriter = FileWriter;

#endif
5 changes: 4 additions & 1 deletion firmware/application/io_wave.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __IO_WAVE_H
#define __IO_WAVE_H

#include "io_file.hpp"

Expand Down Expand Up @@ -181,3 +182,5 @@ class WAVFileWriter : public FileWriter {
Optional<File::Error> update_header();
Optional<File::Error> write_tags();
};

#endif
5 changes: 4 additions & 1 deletion firmware/application/portapack.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __PORTAPACK_H
#define __PORTAPACK_H

#include "portapack_io.hpp"

Expand Down Expand Up @@ -85,3 +86,5 @@ Backlight* backlight();
extern bool async_tx_enabled; // this is for serial tx things, globally

} /* namespace portapack */

#endif
5 changes: 4 additions & 1 deletion firmware/application/usb_serial.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -54,3 +55,5 @@ class USBSerial {
};

} // namespace portapack

#endif
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_cdc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_descriptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_device_to_host.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -56,3 +57,5 @@ size_t fillOBuffer(OutputQueue* oqp, const uint8_t* bp, size_t n);
#ifdef __cplusplus
}
#endif

#endif
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_endpoints.h
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_event.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -32,3 +33,5 @@ void on_channel_closed(void);
#ifdef __cplusplus
}
#endif

#endif
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_host_to_device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
5 changes: 4 additions & 1 deletion firmware/application/usb_serial_shell.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -29,3 +30,5 @@
class EventDispatcher;

void create_shell(EventDispatcher* evtd);

#endif
5 changes: 4 additions & 1 deletion firmware/baseband/proc_spectrum_painter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -46,3 +47,5 @@ class SpectrumPainterProcessor : public BasebandProcessor {
return 0;
}
};

#endif
5 changes: 4 additions & 1 deletion firmware/common/backlight.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __BACKLIGHT_H
#define __BACKLIGHT_H

#include <cstdint>

Expand Down Expand Up @@ -118,3 +119,5 @@ class BacklightCAT4004 : public BacklightBase {
};

} /* namespace portapack */

#endif
5 changes: 4 additions & 1 deletion firmware/common/buffer_exchange.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __BUFFER_EXCHANGE_H
#define __BUFFER_EXCHANGE_H

#include "ch.h"

Expand Down Expand Up @@ -110,3 +111,5 @@ class BufferExchange {

StreamBuffer* get_prefill(FIFO<StreamBuffer*>* fifo);
};

#endif
5 changes: 4 additions & 1 deletion firmware/common/i2cdev_ppmod.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __I2CDEV_PPMOD_H
#define __I2CDEV_PPMOD_H

#include <cstdint>
#include <array>
Expand Down Expand Up @@ -71,3 +72,5 @@ class I2cDev_PPmod : public I2cDev {
};

} /* namespace i2cdev */

#endif
5 changes: 4 additions & 1 deletion firmware/common/random.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __RANDOM_H
#define __RANDOM_H

/* Period parameters */
#define N 624
Expand All @@ -33,3 +34,5 @@
/* initializes state[N] with a seed */
extern void init_genrand(unsigned long s);
extern long genrand_int31(void);

#endif
5 changes: 4 additions & 1 deletion firmware/test/application/mock_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,8 @@
* Boston, MA 02110-1301, USA.
*/

#pragma once
#ifndef __MOCK_FILE_H
#define __MOCK_FILE_H

#include "file.hpp"
#include <cstring>
Expand Down Expand Up @@ -87,3 +88,5 @@ class MockFile {
std::string data_;
uint32_t offset_{0};
};

#endif

0 comments on commit fcc52e8

Please sign in to comment.