Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some random errors and warnings #78679

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions samples/subsys/shell/shell_module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ project(shell_module)
target_sources(app PRIVATE src/main.c src/test_module.c)
target_sources_ifdef(CONFIG_SHELL_DYNAMIC_CMDS app PRIVATE src/dynamic_cmd.c)
target_sources_ifdef(CONFIG_SHELL_BACKEND_SERIAL app PRIVATE src/uart_reinit.c)
target_sources_ifdef(CONFIG_SHELL_START_OBSCURED app PRIVATE src/login_cmd.c)
65 changes: 65 additions & 0 deletions samples/subsys/shell/shell_module/src/login_cmd.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/*
* Copyright (c) 2015 Intel Corporation
*
* SPDX-License-Identifier: Apache-2.0
*/

#include <zephyr/kernel.h>
#include <zephyr/shell/shell.h>
#include <zephyr/init.h>

#define DEFAULT_PASSWORD "zephyr"

static int login_init(void)
{
printk("Shell Login Demo\nHint: password = %s\n", DEFAULT_PASSWORD);
if (!CONFIG_SHELL_CMD_ROOT[0]) {
shell_set_root_cmd("login");
}
return 0;
}

static int check_passwd(char *passwd)
{
/* example only -- not recommended for production use */
return strcmp(passwd, DEFAULT_PASSWORD);
}

static int cmd_login(const struct shell *sh, size_t argc, char **argv)
{
static uint32_t attempts;

if (check_passwd(argv[1]) != 0) {
shell_error(sh, "Incorrect password!");
attempts++;
if (attempts > 3) {
k_sleep(K_SECONDS(attempts));
}
return -EINVAL;
}

/* clear history so password not visible there */
z_shell_history_purge(sh->history);
shell_obscure_set(sh, false);
shell_set_root_cmd(NULL);
shell_prompt_change(sh, "uart:~$ ");
shell_print(sh, "Shell Login Demo\n");
shell_print(sh, "Hit tab for help.\n");
attempts = 0;
return 0;
}

static int cmd_logout(const struct shell *sh, size_t argc, char **argv)
{
shell_set_root_cmd("login");
shell_obscure_set(sh, true);
shell_prompt_change(sh, "login: ");
shell_print(sh, "\n");
return 0;
}

SHELL_CMD_ARG_REGISTER(login, NULL, "<password>", cmd_login, 2, 0);

SHELL_CMD_REGISTER(logout, NULL, "Log out.", cmd_logout);

SYS_INIT(login_init, APPLICATION, CONFIG_APPLICATION_INIT_PRIORITY);
60 changes: 0 additions & 60 deletions samples/subsys/shell/shell_module/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -240,55 +240,6 @@ static int cmd_version(const struct shell *sh, size_t argc, char **argv)
return 0;
}

#define DEFAULT_PASSWORD "zephyr"

static void login_init(void)
{
printk("Shell Login Demo\nHint: password = %s\n", DEFAULT_PASSWORD);
if (!CONFIG_SHELL_CMD_ROOT[0]) {
shell_set_root_cmd("login");
}
}

static int check_passwd(char *passwd)
{
/* example only -- not recommended for production use */
return strcmp(passwd, DEFAULT_PASSWORD);
}

static int cmd_login(const struct shell *sh, size_t argc, char **argv)
{
static uint32_t attempts;

if (check_passwd(argv[1]) != 0) {
shell_error(sh, "Incorrect password!");
attempts++;
if (attempts > 3) {
k_sleep(K_SECONDS(attempts));
}
return -EINVAL;
}

/* clear history so password not visible there */
z_shell_history_purge(sh->history);
shell_obscure_set(sh, false);
shell_set_root_cmd(NULL);
shell_prompt_change(sh, "uart:~$ ");
shell_print(sh, "Shell Login Demo\n");
shell_print(sh, "Hit tab for help.\n");
attempts = 0;
return 0;
}

static int cmd_logout(const struct shell *sh, size_t argc, char **argv)
{
shell_set_root_cmd("login");
shell_obscure_set(sh, true);
shell_prompt_change(sh, "login: ");
shell_print(sh, "\n");
return 0;
}

static int set_bypass(const struct shell *sh, shell_bypass_cb_t bypass)
{
static bool in_use;
Expand Down Expand Up @@ -395,13 +346,6 @@ SHELL_CMD_ARG_REGISTER(version, NULL, "Show kernel version", cmd_version, 1, 0);

SHELL_CMD_ARG_REGISTER(bypass, NULL, "Bypass shell", cmd_bypass, 1, 0);

SHELL_COND_CMD_ARG_REGISTER(CONFIG_SHELL_START_OBSCURED, login, NULL,
"<password>", cmd_login, 2, 0);

SHELL_COND_CMD_REGISTER(CONFIG_SHELL_START_OBSCURED, logout, NULL,
"Log out.", cmd_logout);


/* Create a set of commands. Commands to this set are added using @ref SHELL_SUBCMD_ADD
* and @ref SHELL_SUBCMD_COND_ADD.
*/
Expand Down Expand Up @@ -429,10 +373,6 @@ SHELL_CMD_REGISTER(section_cmd, &sub_section_cmd,

int main(void)
{
if (IS_ENABLED(CONFIG_SHELL_START_OBSCURED)) {
login_init();
}

#if DT_NODE_HAS_COMPAT(DT_CHOSEN(zephyr_shell_uart), zephyr_cdc_acm_uart)
const struct device *dev;
uint32_t dtr = 0;
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/adv.c
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ static int hci_set_ad_ext(struct bt_le_ext_adv *adv, uint16_t hci_op,
}

if (total_len_bytes > bt_dev.le.max_adv_data_len) {
LOG_WRN("adv or scan rsp data too large (%d > max %d)", total_len_bytes,
LOG_WRN("adv or scan rsp data too large (%zu > max %u)", total_len_bytes,
bt_dev.le.max_adv_data_len);
return -EDOM;
}
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/buf.c
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ struct net_buf *bt_buf_make_view(struct net_buf *view,

__ASSERT_NO_MSG(!bt_buf_has_view(parent));

LOG_DBG("make-view %p viewsize %u meta %p", view, len, meta);
LOG_DBG("make-view %p viewsize %zu meta %p", view, len, meta);

net_buf_simple_clone(&parent->b, &view->b);
view->size = net_buf_headroom(parent) + len;
Expand Down
4 changes: 2 additions & 2 deletions subsys/bluetooth/host/conn.c
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@
window = bt_buf_make_view(window, outside,
winsize, &get_frag_md(window)->view_meta);

LOG_DBG("get-acl-frag: outside %p window %p size %d", outside, window, winsize);
LOG_DBG("get-acl-frag: outside %p window %p size %zu", outside, window, winsize);

return window;
}
Expand Down Expand Up @@ -651,9 +651,9 @@
return -EIO;
}

LOG_DBG("conn %p buf %p len %u buf->len %u cb %p ud %p",
LOG_DBG("conn %p buf %p len %zu buf->len %u cb %p ud %p",
conn, buf, len, buf->len, cb, ud);

Check notice on line 656 in subsys/bluetooth/host/conn.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/host/conn.c:656 - LOG_DBG("conn %p buf %p len %zu buf->len %u cb %p ud %p", - conn, buf, len, buf->len, cb, ud); + LOG_DBG("conn %p buf %p len %zu buf->len %u cb %p ud %p", conn, buf, len, buf->len, cb, ud);
/* Acquire the right to send 1 packet to the controller */
if (k_sem_take(bt_conn_get_pkts(conn), K_NO_WAIT)) {
/* This shouldn't happen now that we acquire the resources
Expand Down
2 changes: 1 addition & 1 deletion subsys/bluetooth/host/l2cap.c
Original file line number Diff line number Diff line change
Expand Up @@ -933,9 +933,9 @@
struct bt_l2cap_hdr *hdr;
uint16_t pdu_len = get_pdu_len(lechan, pdu);

LOG_DBG("Adding L2CAP PDU header: buf %p chan %p len %zu / %zu",
LOG_DBG("Adding L2CAP PDU header: buf %p chan %p len %u / %u",
pdu, lechan, pdu_len, pdu->len);

Check notice on line 938 in subsys/bluetooth/host/l2cap.c

View workflow job for this annotation

GitHub Actions / Run compliance checks on patch series (PR)

You may want to run clang-format on this change

subsys/bluetooth/host/l2cap.c:938 - LOG_DBG("Adding L2CAP PDU header: buf %p chan %p len %u / %u", - pdu, lechan, pdu_len, pdu->len); + LOG_DBG("Adding L2CAP PDU header: buf %p chan %p len %u / %u", pdu, lechan, pdu_len, + pdu->len);
LOG_HEXDUMP_DBG(pdu->data, pdu->len, "PDU payload");

hdr = net_buf_push(pdu, sizeof(*hdr));
Expand Down
Loading