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

internal.c var initialization for Espressif Component Manager #589

Merged
merged 2 commits into from
Sep 24, 2023

Conversation

gojimmypi
Copy link
Contributor

@gojimmypi gojimmypi commented Sep 21, 2023

Required for #588, this PR addresses some minor issues where the Espressif compiler using cmake complained as shown below.

See the wolfSSH preview component: https://components-staging.espressif.com/components/gojimmypi/mywolfssh

Test drive the template example:

# Setup ESP-IDF
export WRK_IDF_PATH=/mnt/c/SysGCC/esp32/esp-idf/v5.1
echo "Run export.sh from ${WRK_IDF_PATH}"
. ${WRK_IDF_PATH}/export.sh

# fetch and build the example
idf.py create-project-from-example "gojimmypi/mywolfssh^1.0.5-test:wolfssh_template"
cd wolfssh_template
idf.py build

If these errors are observed, the wolfssluser_settings.h needs to be adjusted by adding #define WOLFSSH_TERM:

C:/test/mqtest/6/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/ssh.c:1344:8: error: 'WOLFSSH' has no member named 'termResizeCb'
 1344 |     ssh->termResizeCb = cb;
      |        ^~
C:/test/mqtest/6/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/ssh.c: In function 'wolfSSH_SetTerminalResizeCtx':
C:/test/mqtest/6/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/ssh.c:1350:8: error: 'WOLFSSH' has no member named 'termCtx'
 1350 |     ssh->termCtx = usrCtx;
      |        ^~

Errors observed prior to and addressed in this PR:

C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c: In function 'IdentifyKey':
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:875:9: warning: unused variable 'dynType' [-Wunused-variable]
  875 |     int dynType = isPrivate ? DYNTYPE_PRIVKEY : DYNTYPE_PUBKEY;
      |         ^~~~~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c: In function 'SendKexInit':
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:8399:15: error: 'algoCount' may be used uninitialized [-Werror=maybe-uninitialized]
 8399 |         ret = BuildNameList(keyAlgoNames, keyAlgoNamesSz, algo, algoCount);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:8327:12: note: 'algoCount' was declared here
 8327 |     word32 algoCount, idx = 0, payloadSz = 0,
      |            ^~~~~~~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:8399:15: error: 'algo' may be used uninitialized [-Werror=maybe-uninitialized]
 8399 |         ret = BuildNameList(keyAlgoNames, keyAlgoNamesSz, algo, algoCount);
      |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:8326:17: note: 'algo' was declared here
 8326 |     const byte* algo;
      |                 ^~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c: In function 'SendKexDhReply':
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:9751:25: error: 'output' may be used uninitialized [-Werror=maybe-uninitialized]
 9751 |         if (fPad) output[idx++] = 0;
      |                         ^
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:9054:11: note: 'output' was declared here
 9054 |     byte* output;
      |           ^~~~~~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:9751:29: error: 'idx' may be used uninitialized [-Werror=maybe-uninitialized]
 9751 |         if (fPad) output[idx++] = 0;
      |                          ~~~^~
C:/test/mqtest/5/wolfssh_template/managed_components/gojimmypi__mywolfssh/src/internal.c:9055:12: note: 'idx' was declared here
 9055 |     word32 idx;
      |            ^~~
cc1.exe: some warnings being treated as errors
[1000/1008] Building C object esp-idf/gojimmypi__mywolfssl...s/__idf_gojimmypi__mywolfssl.dir/wolfcrypt/test/test.c.objninja: build stopped: subcommand failed.
ninja failed with exit code 1, output of the command is in the C:\test\mqtest\5\wolfssh_template\build\log\idf_py_stderr_output_89800 and C:\test\mqtest\5\wolfssh_template\build\log\idf_py_stdout_output_89800

See wolfSSL/wolfssl#6234 for a roadmap of all Espressif improvements currently in progress.

src/internal.c Outdated Show resolved Hide resolved
@ejohnstown ejohnstown self-requested a review September 22, 2023 23:31
@ejohnstown ejohnstown removed their assignment Sep 22, 2023
@ejohnstown ejohnstown merged commit e0ba0cb into wolfSSL:master Sep 24, 2023
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants