Skip to content

Commit

Permalink
random: Include header where it is used
Browse files Browse the repository at this point in the history
Unit tests were failing to build because random header was included by
kernel_includes.h. The problem is that rand32.h includes a generated
file that is either not generated or not included when building unit
tests. Also, it is better to limit the scope of this file to where it is
used.

Signed-off-by: Flavio Ceolin <flavio.ceolin@intel.com>
  • Loading branch information
Flavio Ceolin authored and nashif committed Jul 9, 2020
1 parent 6216c6c commit c4f7fae
Show file tree
Hide file tree
Showing 60 changed files with 62 additions and 1 deletion.
1 change: 1 addition & 0 deletions drivers/ethernet/eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
#define ZEPHYR_DRIVERS_ETHERNET_ETH_H_

#include <zephyr/types.h>
#include <random/rand32.h>

/* helper macro to return mac address octet from local_mac_address prop */
#define NODE_MAC_ADDR_OCTET(node, n) DT_PROP_BY_IDX(node, local_mac_address, n)
Expand Down
1 change: 1 addition & 0 deletions drivers/ieee802154/ieee802154_uart_pipe.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <init.h>
#include <net/net_if.h>
#include <net/net_pkt.h>
#include <random/rand32.h>

#include <drivers/console/uart_pipe.h>
#include <net/ieee802154_radio.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/modem/wncm14a2a.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LOG_MODULE_REGISTER(LOG_DOMAIN);
#include <drivers/gpio.h>
#include <device.h>
#include <init.h>
#include <random/rand32.h>

#include <net/net_context.h>
#include <net/net_if.h>
Expand Down
1 change: 1 addition & 0 deletions drivers/net/ppp.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ LOG_MODULE_REGISTER(net_ppp, LOG_LEVEL);
#include <sys/crc.h>
#include <drivers/uart.h>
#include <drivers/console/uart_mux.h>
#include <random/rand32.h>

#include "../../subsys/net/ip/net_stats.h"
#include "../../subsys/net/ip/net_private.h"
Expand Down
1 change: 1 addition & 0 deletions drivers/net/slip.c
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ LOG_MODULE_REGISTER(LOG_MODULE_NAME);
#include <net/net_core.h>
#include <net/dummy.h>
#include <drivers/console/uart_pipe.h>
#include <random/rand32.h>

#define SLIP_END 0300
#define SLIP_ESC 0333
Expand Down
1 change: 0 additions & 1 deletion include/kernel_includes.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
#include <mempool_sys.h>
#endif
#include <kernel_version.h>
#include <random/rand32.h>
#include <syscall.h>
#include <sys/printk.h>
#include <arch/cpu.h>
Expand Down
1 change: 1 addition & 0 deletions kernel/thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include <stdbool.h>
#include <irq_offload.h>
#include <sys/check.h>
#include <random/rand32.h>

#ifdef CONFIG_THREAD_MONITOR
/* This lock protects the linked list of active threads; i.e. the
Expand Down
1 change: 1 addition & 0 deletions samples/bluetooth/peripheral_csc/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <random/rand32.h>
#include <sys/printk.h>
#include <sys/byteorder.h>
#include <zephyr.h>
Expand Down
1 change: 1 addition & 0 deletions samples/net/cloud/mqtt_azure/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ LOG_MODULE_REGISTER(mqtt_azure, LOG_LEVEL_DBG);
#include <net/mqtt.h>

#include <sys/printk.h>
#include <random/rand32.h>
#include <string.h>
#include <errno.h>

Expand Down
1 change: 1 addition & 0 deletions samples/net/mqtt_publisher/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LOG_MODULE_REGISTER(net_mqtt_publisher_sample, LOG_LEVEL_DBG);
#include <zephyr.h>
#include <net/socket.h>
#include <net/mqtt.h>
#include <random/rand32.h>

#include <string.h>
#include <errno.h>
Expand Down
1 change: 1 addition & 0 deletions samples/net/sockets/echo_client/src/tcp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_DECLARE(net_echo_client_sample, LOG_LEVEL_DBG);

#include <net/socket.h>
#include <net/tls_credentials.h>
#include <random/rand32.h>

#include "common.h"
#include "ca_certificate.h"
Expand Down
1 change: 1 addition & 0 deletions samples/net/sockets/echo_client/src/udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_DECLARE(net_echo_client_sample, LOG_LEVEL_DBG);

#include <net/socket.h>
#include <net/tls_credentials.h>
#include <random/rand32.h>

#include "common.h"
#include "ca_certificate.h"
Expand Down
1 change: 1 addition & 0 deletions samples/net/sockets/websocket_client/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LOG_MODULE_REGISTER(net_websocket_client_sample, LOG_LEVEL_DBG);
#include <net/socket.h>
#include <net/tls_credentials.h>
#include <net/websocket.h>
#include <random/rand32.h>
#include <shell/shell.h>

#include "ca_certificate.h"
Expand Down
1 change: 1 addition & 0 deletions samples/net/wpan_serial/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(wpan_serial, CONFIG_USB_DEVICE_LOG_LEVEL);
#include <drivers/uart.h>
#include <zephyr.h>
#include <usb/usb_device.h>
#include <random/rand32.h>

#include <net/buf.h>
#include <net_private.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/dhcpv4.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(net_dhcpv4, CONFIG_NET_DHCPV4_LOG_LEVEL);

#include <errno.h>
#include <inttypes.h>
#include <random/rand32.h>
#include <net/net_core.h>
#include <net/net_pkt.h>
#include <net/net_if.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/ipv4_autoconf.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(net_ipv4_autoconf, CONFIG_NET_IPV4_AUTO_LOG_LEVEL);
#include <net/net_pkt.h>
#include <net/net_core.h>
#include <net/net_if.h>
#include <random/rand32.h>

#include "ipv4_autoconf_internal.h"

Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/ipv6_fragment.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LOG_MODULE_DECLARE(net_ipv6, CONFIG_NET_IPV6_LOG_LEVEL);
#include <net/net_stats.h>
#include <net/net_context.h>
#include <net/net_mgmt.h>
#include <random/rand32.h>
#include "net_private.h"
#include "connection.h"
#include "icmpv6.h"
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/net_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
LOG_MODULE_REGISTER(net_ctx, CONFIG_NET_CONTEXT_LOG_LEVEL);

#include <kernel.h>
#include <random/rand32.h>
#include <string.h>
#include <errno.h>
#include <stdbool.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/net_if.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LOG_MODULE_REGISTER(net_if, CONFIG_NET_IF_LOG_LEVEL);
#include <init.h>
#include <kernel.h>
#include <linker/sections.h>
#include <random/rand32.h>
#include <syscall_handler.h>
#include <stdlib.h>
#include <string.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/net_shell.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(net_shell, LOG_LEVEL_DBG);

#include <zephyr.h>
#include <kernel_internal.h>
#include <random/rand32.h>
#include <stdlib.h>
#include <stdio.h>
#include <shell/shell.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/tcp2.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LOG_MODULE_REGISTER(net_tcp, CONFIG_NET_TCP_LOG_LEVEL);
#include <stdio.h>
#include <stdlib.h>
#include <zephyr.h>
#include <random/rand32.h>
#include <net/net_pkt.h>
#include <net/net_context.h>
#include <net/udp.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/tcp_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
#define __TCP_INTERNAL_H

#include <zephyr/types.h>
#include <random/rand32.h>

#include <net/net_core.h>
#include <net/net_ip.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/ip/trickle.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(net_trickle, CONFIG_NET_TRICKLE_LOG_LEVEL);

#include <errno.h>
#include <sys/util.h>
#include <random/rand32.h>

#include <net/net_core.h>
#include <net/trickle.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/canbus/6locan.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ LOG_MODULE_REGISTER(net_l2_canbus, CONFIG_NET_L2_CANBUS_LOG_LEVEL);
#include <net/ethernet.h>
#include <net/net_ip.h>
#include <string.h>
#include <random/rand32.h>

#define NET_CAN_WFTMAX 2
#define NET_CAN_ALLOC_TIMEOUT K_MSEC(100)
Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/ethernet/ethernet.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ LOG_MODULE_REGISTER(net_ethernet, CONFIG_NET_L2_ETHERNET_LOG_LEVEL);
#include <net/ethernet.h>
#include <net/ethernet_mgmt.h>
#include <net/gptp.h>
#include <random/rand32.h>

#if defined(CONFIG_NET_LLDP)
#include <net/lldp.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/ethernet/gptp/gptp.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LOG_MODULE_REGISTER(net_gptp, CONFIG_NET_GPTP_LOG_LEVEL);
#include <net/net_pkt.h>
#include <ptp_clock.h>
#include <net/ethernet_mgmt.h>
#include <random/rand32.h>

#include <net/gptp.h>

Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/ieee802154/ieee802154_radio_csma_ca.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LOG_MODULE_REGISTER(net_ieee802154_csma, CONFIG_NET_L2_IEEE802154_LOG_LEVEL);
#include <net/net_if.h>

#include <sys/util.h>
#include <random/rand32.h>

#include <stdlib.h>
#include <errno.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/l2/ppp/fsm.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ LOG_MODULE_DECLARE(net_l2_ppp, CONFIG_NET_L2_PPP_LOG_LEVEL);
#include <net/net_pkt.h>

#include <net/ppp.h>
#include <random/rand32.h>

#include "net_private.h"

Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/dns/resolve.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
LOG_MODULE_REGISTER(net_dns_resolve, CONFIG_DNS_RESOLVER_LOG_LEVEL);

#include <zephyr/types.h>
#include <random/rand32.h>
#include <string.h>
#include <errno.h>
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/openthread/platform/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include <kernel.h>
#include <logging/log.h>
#include <settings/settings.h>
#include <random/rand32.h>

#include <openthread/platform/settings.h>

Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/sockets/sockets_tls.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_sock_tls, CONFIG_NET_SOCKETS_LOG_LEVEL);
#include <sys/util.h>
#include <net/net_context.h>
#include <net/socket.h>
#include <random/rand32.h>
#include <syscall_handler.h>
#include <sys/fdtable.h>

Expand Down
1 change: 1 addition & 0 deletions subsys/net/lib/websocket/websocket.c
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ LOG_MODULE_REGISTER(net_websocket, CONFIG_NET_WEBSOCKET_LOG_LEVEL);
#include <net/http_client.h>
#include <net/websocket.h>

#include <random/rand32.h>
#include <sys/byteorder.h>
#include <sys/base64.h>
#include <mbedtls/sha1.h>
Expand Down
1 change: 1 addition & 0 deletions tests/benchmarks/mbedtls/src/benchmark.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@

#include <zephyr/types.h>
#include <sys/byteorder.h>
#include <random/rand32.h>

#include "kernel.h"

Expand Down
1 change: 1 addition & 0 deletions tests/crypto/rand32/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

#include <ztest.h>
#include <kernel_internal.h>
#include <random/rand32.h>

#define N_VALUES 10

Expand Down
1 change: 1 addition & 0 deletions tests/crypto/tinycrypt/src/ecc_dsa.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
#include <test_utils.h>
#include "test_ecc_utils.h"
#include <sys/util.h>
#include <random/rand32.h>

#include <stdio.h>
#include <stdlib.h>
Expand Down
1 change: 1 addition & 0 deletions tests/kernel/sched/deadline/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
*/
#include <zephyr.h>
#include <ztest.h>
#include <random/rand32.h>

#define NUM_THREADS 8
#define STACK_SIZE (256 + CONFIG_TEST_EXTRA_STACKSIZE)
Expand Down
1 change: 1 addition & 0 deletions tests/kernel/timer/timer_api/src/timer_convert.c
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
#include <ztest.h>
#include <zephyr/types.h>
#include <sys/time_units.h>
#include <random/rand32.h>

#define NUM_RANDOM 100

Expand Down
1 change: 1 addition & 0 deletions tests/net/arp/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_ARP_LOG_LEVEL);
#include <net/net_ip.h>
#include <net/dummy.h>
#include <ztest.h>
#include <random/rand32.h>

#include "arp.h"

Expand Down
1 change: 1 addition & 0 deletions tests/net/checksum_offload/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(net_test, NET_LOG_LEVEL);
#include <errno.h>
#include <sys/printk.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/context/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_CONTEXT_LOG_LEVEL);
#include <errno.h>
#include <sys/printk.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <tc_util.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/hostname/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_test, NET_LOG_LEVEL);
#include <stddef.h>
#include <string.h>
#include <errno.h>
#include <random/rand32.h>
#include <sys/printk.h>
#include <linker/sections.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/iface/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ LOG_MODULE_REGISTER(net_test, NET_LOG_LEVEL);
#include <errno.h>
#include <sys/printk.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/ip-addr/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL);
#include <device.h>
#include <init.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/ipv6/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL);
#include <string.h>
#include <errno.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/ipv6_fragment/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_NET_IPV6_LOG_LEVEL);
#include <errno.h>
#include <sys/printk.h>
#include <linker/sections.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/lib/dns_addremove/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_DNS_RESOLVER_LOG_LEVEL);
#include <string.h>
#include <errno.h>
#include <sys/printk.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
1 change: 1 addition & 0 deletions tests/net/lib/dns_resolve/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ LOG_MODULE_REGISTER(net_test, CONFIG_DNS_RESOLVER_LOG_LEVEL);
#include <string.h>
#include <errno.h>
#include <sys/printk.h>
#include <random/rand32.h>

#include <ztest.h>

Expand Down
2 changes: 2 additions & 0 deletions tests/net/lib/mqtt_publisher/src/test_mqtt_publish.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ LOG_MODULE_REGISTER(net_test, LOG_LEVEL_WRN);
#include <string.h>
#include <errno.h>

#include <random/rand32.h>

#include "config.h"

/* This is mqtt payload message. */
Expand Down
1 change: 1 addition & 0 deletions tests/net/lib/mqtt_pubsub/src/test_mqtt_pubsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ LOG_MODULE_REGISTER(net_test, LOG_LEVEL_WRN);
#include <ztest.h>
#include <net/socket.h>
#include <net/mqtt.h>
#include <random/rand32.h>

#include <string.h>
#include <errno.h>
Expand Down
Loading

0 comments on commit c4f7fae

Please sign in to comment.