radiotap / radiotap-library

radiotap parser C library
ISC License
106 stars 65 forks source link

Fix CMake and compiler warnings #13

Closed gemesa closed 12 months ago

gemesa commented 1 year ago

Hi @jmberg, I am coming from the aircrack-ng project where this radiotap library is being utilized. Recently I started experimenting with the aircrack radiotap code which is a fork of your implementation. I noticed some warnings which I fixed and submitted a PR where it was suggested to me to submit these changes here also.

My changes:

Warnings before my fixes:

$ 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.6s)
-- Generating done (0.0s)
-- Build files have been written to: /home/gemesa/git-repos/radiotap-library

$ 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/radiotap-library/radiotap_iter.h:4,
                 from /home/gemesa/git-repos/radiotap-library/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"
      |   ^~~~~~~
/home/gemesa/git-repos/radiotap-library/radiotap.c: In function ‘ieee80211_radiotap_iterator_init’:
/home/gemesa/git-repos/radiotap-library/radiotap.c:113:34: warning: taking address of packed member of ‘struct ieee80211_radiotap_header’ may result in an unaligned pointer value [-Waddress-of-packed-member]
  113 |         iterator->_next_bitmap = &radiotap_header->it_present;
      |                                  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
[ 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/radiotap-library/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/radiotap-library/parse.c: In function ‘print_radiotap_namespace’:
/home/gemesa/git-repos/radiotap-library/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

After my fixes:

$ 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/radiotap-library

$ 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
jmberg commented 12 months ago

Looks like I just merged some similar things ... care to check?

gemesa commented 12 months ago

Sure, I removed 2 redundant commits from this PR (which were duplicates of https://github.com/radiotap/radiotap-library/commit/2da183c275e63a44c3a56a9393e1533836762312 and https://github.com/radiotap/radiotap-library/commit/48a09c0f2e7153060a0d9f9e4166b3d18f0a85de). Please check the remaining changes.