8000 all: Unify header guard usage. · lable/micropython@299bc62 · GitHub
[go: up one dir, main page]

Skip to content

Commit 299bc62

Browse files
webmeisterdpgeorge
authored andcommitted
all: Unify header guard usage.
The code conventions suggest using header guards, but do not define how those should look like and instead point to existing files. However, not all existing files follow the same scheme, sometimes omitting header guards altogether, sometimes using non-standard names, making it easy to accidentally pick a "wrong" example. This commit ensures that all header files of the MicroPython project (that were not simply copied from somewhere else) follow the same pattern, that was already present in the majority of files, especially in the py folder. The rules are as follows. Naming convention: * start with the words MICROPY_INCLUDED * contain the full path to the file * replace special characters with _ In addition, there are no empty lines before #ifndef, between #ifndef and one empty line before #endif. #endif is followed by a comment containing the name of the guard macro. py/grammar.h cannot use header guards by design, since it has to be included multiple times in a single C file. Several other files also do not need header guards as they are only used internally and guaranteed to be included only once: * MICROPY_MPHALPORT_H * mpconfigboard.h * mpconfigport.h * mpthreadport.h * pin_defs_*.h * qstrdefs*.h
1 parent d91c117 commit 299bc62

File tree

181 files changed

+574
-414
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

181 files changed

+574
-414
lines changed

cc3200/bootmgr/bootmgr.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef __BOOTMGR_H__
28-
#define __BOOTMGR_H__
26+
#ifndef MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H
27+
#define MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H
2928

3029
//****************************************************************************
3130
//
@@ -66,4 +65,4 @@ extern void Run(unsigned long);
6665
}
6766
#endif
6867

69-
#endif //__BOOTMGR_H__
68+
#endif // MICROPY_INCLUDED_CC3200_BOOTMGR_BOOTMGR_H

cc3200/bootmgr/flc.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef __FLC_H__
28-
#define __FLC_H__
26+
#ifndef MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H
27+
#define MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H
2928

3029
/******************************************************************************
3130
@@ -93,4 +92,4 @@ typedef struct _sBootInfo_t
9392
}
9493
#endif
9594

96-
#endif /* __FLC_H__ */
95+
#endif // MICROPY_INCLUDED_CC3200_BOOTMGR_FLC_H

cc3200/ftp/ftp.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef FTP_H_
28-
#define FTP_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_FTP_FTP_H
27+
#define MICROPY_INCLUDED_CC3200_FTP_FTP_H
2928

3029
/******************************************************************************
3130
DECLARE EXPORTED FUNCTIONS
@@ -36,4 +35,4 @@ extern void ftp_enable (void);
3635
extern void ftp_disable (void);
3736
extern void ftp_reset (void);
3837

39-
#endif /* FTP_H_ */
38+
#endif // MICROPY_INCLUDED_CC3200_FTP_FTP_H

cc3200/ftp/updater.h

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
28-
#ifndef UPDATER_H_
29-
#define UPDATER_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_FTP_UPDATER_H
27+
#define MICROPY_INCLUDED_CC3200_FTP_UPDATER_H
3028

3129
extern void updater_pre_init (void);
3230
extern bool updater_check_path (void *path);
@@ -35,4 +33,4 @@ extern bool updater_write (uint8_t *buf, uint32_t len);
3533
extern void updater_finnish (void);
3634
extern bool updater_verify (uint8_t *rbuff, uint8_t *hasbuff);
3735

38- 10000
#endif /* UPDATER_H_ */
36+
#endif // MICROPY_INCLUDED_CC3200_FTP_UPDATER_H

cc3200/hal/cc3200_hal.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,6 @@
2424
* THE SOFTWARE.
2525
*/
2626

27-
#ifndef CC3200_LAUNCHXL_HAL_CC3200_HAL_H_
28-
#define CC3200_LAUNCHXL_HAL_CC3200_HAL_H_
29-
3027
#include <stdint.h>
3128
#include <stdbool.h>
3229

@@ -69,5 +66,3 @@ extern void mp_hal_set_interrupt_char (int c);
6966

7067
#define mp_hal_delay_us(usec) UtilsDelay(UTILS_DELAY_US_TO_COUNT(usec))
7168
#define mp_hal_ticks_cpu() (SysTickPeriodGet() - SysTickValueGet())
72-
73-
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */

cc3200/misc/antenna.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef _ANTENNA_H_
28-
#define _ANTENNA_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H
27+
#define MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H
2928

3029
typedef enum {
3130
ANTENNA_TYPE_INTERNAL = 0,
@@ -35,4 +34,4 @@ typedef enum {
3534
extern void antenna_init0 (void);
3635
extern void antenna_select (antenna_type_t antenna_type);
3736

38-
#endif /* _ANTENNA_H_ */
37+
#endif // MICROPY_INCLUDED_CC3200_MISC_ANTENNA_H

cc3200/misc/mperror.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef MPERROR_H_
29-
#define MPERROR_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MISC_MPERROR_H
28+
#define MICROPY_INCLUDED_CC3200_MISC_MPERROR_H
3029

3130
extern void NORETURN __fatal_error(const char *msg);
3231

@@ -39,4 +38,4 @@ void mperror_heartbeat_signal (void);
3938
void mperror_enable_heartbeat (bool enable);
4039
bool mperror_is_heartbeat_enabled (void);
4140

42-
#endif // MPERROR_H_
41+
#endif // MICROPY_INCLUDED_CC3200_MISC_MPERROR_H

cc3200/misc/mpexception.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef MPEXCEPTION_H_
29-
#define MPEXCEPTION_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H
28+
#define MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H
3029

3130
extern const char mpexception_value_invalid_arguments[];
3231
extern const char mpexception_num_type_invalid_arguments[];
@@ -40,4 +39,4 @@ extern void mpexception_set_interrupt_char (int c);
4039
extern void mpexception_nlr_jump (void *o);
4140
extern void mpexception_keyboard_nlr_jump (void);
4241

43-
#endif /* MPEXCEPTION_H_ */
42+
#endif // MICROPY_INCLUDED_CC3200_MISC_MPEXCEPTION_H

cc3200/misc/mpirq.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef MPIRQ_H_
28-
#define MPIRQ_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H
27+
#define MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H
2928

3029
/******************************************************************************
3130
DEFINE CONSTANTS
@@ -72,4 +71,4 @@ void mp_irq_remove (const mp_obj_t parent);
7271
void mp_irq_handler (mp_obj_t self_in);
7372
uint mp_irq_translate_priority (uint priority);
7473

75-
#endif /* MPIRQ_H_ */
74+
#endif // MICROPY_INCLUDED_CC3200_MISC_MPIRQ_H

cc3200/mods/modnetwork.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef MODNETWORK_H_
29-
#define MODNETWORK_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODNETWORK_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_MODNETWORK_H
3029

3130
/******************************************************************************
3231
DEFINE CONSTANTS
@@ -71,4 +70,4 @@ extern const mod_network_nic_type_t mod_network_nic_type_wlan;
7170
******************************************************************************/
7271
void mod_network_init0(void);
7372

74-
#endif // MODNETWORK_H_
73+
#endif // MICROPY_INCLUDED_CC3200_MODS_MODNETWORK_H

cc3200/mods/modubinascii.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26+
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H
27+
#define MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H
2628

27-
#ifndef MODUBINASCII_H_
28-
#define MODUBINASCII_H_
2929

30-
31-
#endif /* MODUBINASCII_H_ */
30+
#endif // MICROPY_INCLUDED_CC3200_MODS_MODUBINASCII_H

cc3200/mods/moduos.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef MODUOS_H_
29-
#define MODUOS_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUOS_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_MODUOS_H
3029

3130
#include "py/obj.h"
3231

@@ -45,4 +44,4 @@ typedef struct _os_term_dup_obj_t {
4544
******************************************************************************/
4645
void osmount_unmount_all (void);
4746

48-
#endif // MODUOS_H_
47+
#endif // MICROPY_INCLUDED_CC3200_MODS_MODUOS_H

cc3200/mods/modusocket.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef MODUSOCKET_H_
28-
#define MODUSOCKET_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H
27+
#define MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H
2928

3029
extern const mp_obj_dict_t socket_locals_dict;
3130
extern const mp_stream_p_t socket_stream_p;
@@ -36,4 +35,4 @@ extern void modusocket_socket_delete (int16_t sd);
3635
extern void modusocket_enter_sleep (void);
3736
extern void modusocket_close_all_user_sockets (void);
3837

39-
#endif /* MODUSOCKET_H_ */
38+
#endif // MICROPY_INCLUDED_CC3200_MODS_MODUSOCKET_H

cc3200/mods/modwlan.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef MODWLAN_H_
28-
#define MODWLAN_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MODS_MODWLAN_H
27+
#define MICROPY_INCLUDED_CC3200_MODS_MODWLAN_H
2928

3029
/******************************************************************************
3130
DEFINE CONSTANTS
@@ -97,4 +96,4 @@ extern bool wlan_is_connected (void);
9796
extern void wlan_set_current_time (uint32_t seconds_since_2000);
9897
extern void wlan_off_on (void);
9998

100-
#endif /* MODWLAN_H_ */
99+
#endif // MICROPY_INCLUDED_CC3200_MODS_MODWLAN_H

cc3200/mods/pybadc.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBADC_H_
29-
#define PYBADC_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBADC_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBADC_H
3029

3130
extern const mp_obj_type_t pyb_adc_type;
3231

33-
#endif /* PYBADC_H_ */
32+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBADC_H

cc3200/mods/pybi2c.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBI2C_H_
29-
#define PYBI2C_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBI2C_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBI2C_H
3029

3130
extern const mp_obj_type_t pyb_i2c_type;
3231

33-
#endif // PYBI2C_H_
32+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBI2C_H

cc3200/mods/pybpin.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBPIN_H_
29-
#define PYBPIN_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H
3029

3130
enum {
3231
PORT_A0 = GPIOA0_BASE,
@@ -138,4 +137,4 @@ uint8_t pin_find_peripheral_unit (const mp_obj_t pin, uint8_t fn, uint8_t type);
138137
uint8_t pin_find_peripheral_type (const mp_obj_t pin, uint8_t fn, uint8_t unit);
139138
int8_t pin_find_af_index (const pin_obj_t* pin, uint8_t fn, uint8_t unit, uint8_t type);;
140139

141-
#endif // PYBPIN_H_
140+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBPIN_H

cc3200/mods/pybrtc.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBRTC_H_
29-
#define PYBRTC_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBRTC_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBRTC_H
3029

3130
// RTC triggers
3231
#define PYB_RTC_ALARM0 (0x01)
@@ -56,4 +55,4 @@ extern void pyb_rtc_calc_future_time (uint32_t a_mseconds, uint32_t *f_seconds,
5655
extern void pyb_rtc_repeat_alarm (pyb_rtc_obj_t *self);
5756
extern void pyb_rtc_disable_alarm (void);
5857

59-
#endif // PYBRTC_H_
58+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBRTC_H

cc3200/mods/pybsd.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
#ifndef PYBSD_H_
27-
#define PYBSD_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBSD_H
27+
#define MICROPY_INCLUDED_CC3200_MODS_PYBSD_H
2828

2929
/******************************************************************************
3030
DEFINE PUBLIC TYPES
@@ -41,4 +41,4 @@ typedef struct {
4141
extern pybsd_obj_t pybsd_obj;
4242
extern const mp_obj_type_t pyb_sd_type;
4343

44-
#endif // PYBSD_H_
44+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBSD_H

cc3200/mods/pybsleep.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@
2323
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2424
* THE SOFTWARE.
2525
*/
26-
27-
#ifndef PYBSLEEP_H_
28-
#define PYBSLEEP_H_
26+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H
27+
#define MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H
2928

3029
/******************************************************************************
3130
DEFINE CONSTANTS
@@ -70,4 +69,4 @@ void pyb_sleep_deepsleep (void);
7069
pybsleep_reset_cause_t pyb_sleep_get_reset_cause (void);
7170
pybsleep_wake_reason_t pyb_sleep_get_wake_reason (void);
7271

73-
#endif /* PYBSLEEP_H_ */
72+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBSLEEP_H

cc3200/mods/pybspi.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,10 +24,9 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBSPI_H_
29-
#define PYBSPI_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBSPI_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBSPI_H
3029

3130
extern const mp_obj_type_t pyb_spi_type;
3231

33-
#endif // PYBSPI_H_
32+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBSPI_H

cc3200/mods/pybtimer.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBTIMER_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBTIMER_H
2729

2830
/******************************************************************************
2931
DECLARE EXPORTED DATA
@@ -35,3 +37,4 @@ extern const mp_obj_type_t pyb_timer_type;
3537
******************************************************************************/
3638
void timer_init0 (void);
3739

40+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBTIMER_H

cc3200/mods/pybuart.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@
2424
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
2525
* THE SOFTWARE.
2626
*/
27-
28-
#ifndef PYBUART_H_
29-
#define PYBUART_H_
27+
#ifndef MICROPY_INCLUDED_CC3200_MODS_PYBUART_H
28+
#define MICROPY_INCLUDED_CC3200_MODS_PYBUART_H
3029

3130
typedef enum {
3231
PYB_UART_0 = 0,
@@ -43,4 +42,4 @@ int uart_rx_char(pyb_uart_obj_t *uart_obj);
4342
bool uart_tx_char(pyb_uart_obj_t *self, int c);
4443
bool uart_tx_strn(pyb_uart_obj_t *uart_obj, const char *str, uint len);
4544

46-
#endif // PYBUART_H_
45+
#endif // MICROPY_INCLUDED_CC3200_MODS_PYBUART_H

0 commit comments

Comments
 (0)
0