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

simplereader: Fix compilation #222

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open

simplereader: Fix compilation #222

wants to merge 1 commit into from

Conversation

olheureu
Copy link

@olheureu olheureu commented Aug 9, 2022

Compilation of "simplereader.c" failed with an error message, on ARM7 embedded linux and GCC 9.3.0:

  arm-ngrave-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=[...] -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Wall -Wextra -fPIC -DNDEBUG -I. -I../src -I/[...]/mkspecs/linux-oe-g++ -o simplereader.o simplereader.c
  simplereader.c: In function 'main':
  simplereader.c:181:19: error: 'CborValue' {aka 'struct CborValue'} has no member named 'ptr'
    181 |                 it.ptr - buf, cbor_error_string(err));
        |                   ^
  Makefile:653: recipe for target 'simplereader.o' failed
  make: *** [simplereader.o] Error 1

Fixing the error is pretty simple, because the "struct CborValue" is defined in "src/cbor.h" as:

struct CborValue
 {
     const CborParser *parser;
     union {
         const uint8_t *ptr;
         void *token;
     } source;
     [...]
 };

So we need to specify the "source" member of the "struct CborValue", between "it" and "ptr":

"it.ptr" -> "it.source.ptr"

This fixes the compilation error.

Signed-off-by: Olivier L'Heureux [email protected]
Signed-off-by: Xavier Hendrickx [email protected]
Reviewed-by: Evgeny Beysembaev [email protected]

Compilation of "simplereader.c" failed with an error message, on ARM7
embedded linux and GCC 9.3.0:

  arm-ngrave-linux-gnueabi-gcc -mthumb -mfpu=neon-vfpv4 -mfloat-abi=hard -mcpu=cortex-a7 --sysroot=[...] -c -pipe  -O2 -pipe -g -feliminate-unused-debug-types -ffunction-sections -fdata-sections -Wall -Wextra -fPIC -DNDEBUG -I. -I../src -I/[...]/mkspecs/linux-oe-g++ -o simplereader.o simplereader.c
  simplereader.c: In function 'main':
  simplereader.c:181:19: error: 'CborValue' {aka 'struct CborValue'} has no member named 'ptr'
    181 |                 it.ptr - buf, cbor_error_string(err));
        |                   ^
  Makefile:653: recipe for target 'simplereader.o' failed
  make: *** [simplereader.o] Error 1

Fixing the error is pretty simple, because the "struct CborValue" is
defined in "src/cbor.h" as:

  struct CborValue
  {
      const CborParser *parser;
      union {
          const uint8_t *ptr;
          void *token;
      } source;
      [...]
  };

So we need to specify the "source" member of the "struct CborValue",
between "it" and "ptr":

  "it.ptr" -> "it.source.ptr"

This fixes the compilation error.

Signed-off-by: Olivier L'Heureux <[email protected]>
Signed-off-by: Xavier Hendrickx <[email protected]>
Reviewed-by: Evgeny Beysembaev <[email protected]>
@@ -178,7 +178,7 @@ int main(int argc, char **argv)

if (err) {
fprintf(stderr, "CBOR parsing failure at offset %ld: %s\n",
it.ptr - buf, cbor_error_string(err));
it.source.ptr - buf, cbor_error_string(err));
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is correct, but can you use cbor_value_get_next_byte(&it) instead?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea, I will adapt this PR. I'll need a bit of time...

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