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-
#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

0 commit comments

Comments
 (0)