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

radiotap/parse: fix warnings #2533

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

Conversation

gemesa
Copy link
Contributor

@gemesa gemesa commented Mar 24, 2023

While looking around and experimenting with the radiotap and radiotap/parse code I noticed some CMake/gcc warnings:

$ cd aircrack-ng/lib/radiotap
$ cmake .
CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.


-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/gemesa/git-repos/aircrack-ng/lib/radiotap
$ cmake --build .
[ 20%] Building C object CMakeFiles/radiotap.dir/radiotap.c.o
In file included from /usr/include/bits/libc-header-start.h:33,
                 from /usr/include/stdint.h:26,
                 from /usr/lib/gcc/x86_64-redhat-linux/12/include/stdint.h:9,
                 from /home/gemesa/git-repos/aircrack-ng/lib/radiotap/radiotap_iter.h:4,
                 from /home/gemesa/git-repos/aircrack-ng/lib/radiotap/radiotap.c:14:
/usr/include/features.h:194:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  194 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
[ 40%] Linking C shared library libradiotap.so
[ 40%] Built target radiotap
[ 60%] Building C object CMakeFiles/parse.dir/parse.c.o
In file included from /usr/include/sys/types.h:25,
                 from /home/gemesa/git-repos/aircrack-ng/lib/radiotap/parse.c:1:
/usr/include/features.h:194:3: warning: #warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE" [-Wcpp]
  194 | # warning "_BSD_SOURCE and _SVID_SOURCE are deprecated, use _DEFAULT_SOURCE"
      |   ^~~~~~~
/home/gemesa/git-repos/aircrack-ng/lib/radiotap/parse.c: In function ‘print_radiotap_namespace’:
/home/gemesa/git-repos/aircrack-ng/lib/radiotap/parse.c:42:36: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘__uint64_t’ {aka ‘long unsigned int’} [-Wformat=]
   42 |                 printf("\tTSFT: %llu\n", le64toh(*(unsigned long long *)iter->this_arg));
      |                                 ~~~^
      |                                    |
      |                                    long long unsigned int
      |                                 %lu
[ 80%] Linking C executable parse
[ 80%] Built target parse
[100%] Check examples
Checking 00.bin: OK
Checking 0.bin: OK
Checking 0fcs.bin: OK
Checking 0v0-2.bin: OK
Checking 0v0-3.bin: OK
Checking 0v0-4.bin: OK
Checking 0v0.bin: OK
Checking 1.bin: OK
Checking malformed-vendor.bin: OK
Checking unparsed-vendor.bin: OK
[100%] Built target radiotap_check

So I fixed them:

_BSD_SOURCE (deprecated since glibc 2.20)
...
              Since glibc 2.20, this macro is deprecated.  It now has
              the same effect as defining _DEFAULT_SOURCE, but generates
              a compile-time warning (unless _DEFAULT_SOURCE is also
              defined).  Use _DEFAULT_SOURCE instead.  To allow code
              that requires _BSD_SOURCE in glibc 2.19 and earlier and
              _DEFAULT_SOURCE in glibc 2.20 and later to compile without
              warnings, define both _BSD_SOURCE and _DEFAULT_SOURCE.
  • added a (unsigned long long) cast

And also added -Werror.

After fixing the warnings:

$ cmake .        
-- The C compiler identification is GNU 12.2.1
-- The CXX compiler identification is GNU 12.2.1
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Configuring done (0.5s)
-- Generating done (0.0s)
-- Build files have been written to: /home/gemesa/git-repos/aircrack-ng/lib/radiotap
$ cmake --build .
[ 20%] Building C object CMakeFiles/radiotap.dir/radiotap.c.o
[ 40%] Linking C shared library libradiotap.so
[ 40%] Built target radiotap
[ 60%] Building C object CMakeFiles/parse.dir/parse.c.o
[ 80%] Linking C executable parse
[ 80%] Built target parse
[100%] Check examples
Checking 00.bin: OK
Checking 0.bin: OK
Checking 0fcs.bin: OK
Checking 0v0-2.bin: OK
Checking 0v0-3.bin: OK
Checking 0v0-4.bin: OK
Checking 0v0.bin: OK
Checking 1.bin: OK
Checking malformed-vendor.bin: OK
Checking unparsed-vendor.bin: OK
[100%] Built target radiotap_check

@Mister-X-
Copy link
Collaborator

This code comes from https://github.com/radiotap/radiotap-library so it should ideally be submitted there as well. And we likely want to submit some of our fixes/updates as well.

@ZeroChaos-
Copy link
Collaborator

Adding -Werror for all builds is highly discouraged. It caused warnings to become failures which hurt users as new warning pop up from new compiler versions after a release it made. It would be better to make a debug build type and only define it there.

@gemesa
Copy link
Contributor Author

gemesa commented Mar 24, 2023

This code comes from https://github.com/radiotap/radiotap-library so it should ideally be submitted there as well. And we likely want to submit some of our fixes/updates as well.

I will open a PR there also then.

Adding -Werror for all builds is highly discouraged. It caused warnings to become failures which hurt users as new warning pop up from new compiler versions after a release it made. It would be better to make a debug build type and only define it there.

Good point, I removed it for now.

@gemesa gemesa changed the title radiotap/parse: fix warnings, add -Werror radiotap/parse: fix warnings Mar 24, 2023
@Mister-X-
Copy link
Collaborator

Which we forked in https://github.com/aircrack-ng/radiotap-library

@gemesa
Copy link
Contributor Author

gemesa commented Mar 24, 2023

Which we forked in https://github.com/aircrack-ng/radiotap-library

So we should add it as a submodule to avoid duplication?

@Mister-X-
Copy link
Collaborator

Ideally yes (of our repo). However, I've read that older version of git, this complicates the clone a bit (but I don't know what version 'old' refers to). So I'm not sure it's a good idea.

@gemesa
Copy link
Contributor Author

gemesa commented Mar 26, 2023

This code comes from https://github.com/radiotap/radiotap-library so it should ideally be submitted there as well. And we likely want to submit some of our fixes/updates as well.

I have submitted the changes in this PR + 44f13db and 998bc12. Now waiting for an answer from the maintainer.

Ideally yes (of our repo). However, I've read that older version of git, this complicates the clone a bit (but I don't know what version 'old' refers to). So I'm not sure it's a good idea.

I will investigate this as a next step.

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.

None yet

3 participants