diff options
author | Vic Yang <victoryang@chromium.org> | 2014-06-10 14:29:59 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-11 03:34:17 +0000 |
commit | 2478058b7a327a2c1c573dc887ade1675ffa85cc (patch) | |
tree | c2da6283cd1deadfb7dd2f3d147b35eda249ebc7 | |
parent | 7fb019e43c416a5dac4bf23fa06242397b0f772a (diff) | |
download | chrome-ec-2478058b7a327a2c1c573dc887ade1675ffa85cc.tar.gz |
Emit error when board.h or config_chip.h is included before config.h
If board.h or config_chip.h is included before config.h, CONFIG_* flags
may be incorrect. For example, if config.h says:
...
#define CONFIG_DEFINED_FLAG
...
#include "board.h"
...
And board.h says:
#ifndef __BOARD_H
#define __BOARD_H
...
#undef CONFIG_DEFINED_FLAG
...
#endif
Then this code:
#include "board.h"
#include "config.h"
would results in CONFIG_DEFINED_FLAG being defined, instead of undefined
as stated in board.h.
Avoid this by emitting error when board.h or config_chip.h is included
before config.h.
BUG=None
TEST=make buildall
BRANCH=None
Change-Id: Ic4a8b68e8ab1ef2a4cf9e926ab9008d2b106b943
Signed-off-by: Vic Yang <victoryang@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/203265
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
-rw-r--r-- | board/fruitpie/usb_pd_policy.c | 1 | ||||
-rw-r--r-- | board/keyborg/board.c | 1 | ||||
-rw-r--r-- | board/keyborg/debug.c | 1 | ||||
-rw-r--r-- | board/keyborg/master_slave.c | 2 | ||||
-rw-r--r-- | board/keyborg/spi_comm.c | 1 | ||||
-rw-r--r-- | board/samus_pd/usb_pd_policy.c | 1 | ||||
-rw-r--r-- | include/config.h | 7 |
7 files changed, 8 insertions, 6 deletions
diff --git a/board/fruitpie/usb_pd_policy.c b/board/fruitpie/usb_pd_policy.c index 6ebc04385b..1cc167f5b1 100644 --- a/board/fruitpie/usb_pd_policy.c +++ b/board/fruitpie/usb_pd_policy.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include "board.h" #include "common.h" #include "console.h" #include "gpio.h" diff --git a/board/keyborg/board.c b/board/keyborg/board.c index 9ddaf63270..6db3d5cd66 100644 --- a/board/keyborg/board.c +++ b/board/keyborg/board.c @@ -4,7 +4,6 @@ */ /* Keyborg board-specific configuration */ -#include "board.h" #include "common.h" #include "debug.h" #include "master_slave.h" diff --git a/board/keyborg/debug.c b/board/keyborg/debug.c index e801c1f543..b750683379 100644 --- a/board/keyborg/debug.c +++ b/board/keyborg/debug.c @@ -4,7 +4,6 @@ */ /* GPIO UART debug printf */ -#include "board.h" #include "common.h" #include "printf.h" #include "registers.h" diff --git a/board/keyborg/master_slave.c b/board/keyborg/master_slave.c index eab62b1b73..a74ddf554b 100644 --- a/board/keyborg/master_slave.c +++ b/board/keyborg/master_slave.c @@ -4,7 +4,7 @@ */ /* Master/slave identification */ -#include "board.h" +#include "config.h" #include "debug.h" #include "master_slave.h" #include "registers.h" diff --git a/board/keyborg/spi_comm.c b/board/keyborg/spi_comm.c index f795c3a8f6..444661a23c 100644 --- a/board/keyborg/spi_comm.c +++ b/board/keyborg/spi_comm.c @@ -4,7 +4,6 @@ */ /* Stantum board-specific SPI module */ -#include "board.h" #include "common.h" #include "debug.h" #include "dma.h" diff --git a/board/samus_pd/usb_pd_policy.c b/board/samus_pd/usb_pd_policy.c index 2e2a42d182..793de20f5a 100644 --- a/board/samus_pd/usb_pd_policy.c +++ b/board/samus_pd/usb_pd_policy.c @@ -3,7 +3,6 @@ * found in the LICENSE file. */ -#include "board.h" #include "common.h" #include "console.h" #include "gpio.h" diff --git a/include/config.h b/include/config.h index 43f7cfdbca..1e9826f0a7 100644 --- a/include/config.h +++ b/include/config.h @@ -954,6 +954,13 @@ * Board is included after chip, so that chip defaults can be overridden on a * per-board basis as needed. */ +#ifdef __CROS_EC_CONFIG_CHIP_H +#error Include config.h instead of config_chip.h! +#endif +#ifdef __BOARD_H +#error Include config.h instead of board.h! +#endif + #include "config_chip.h" #include "board.h" |