nsensfel / relabsd

Turns your input devices into joysticks by converting relative axes into absolute ones.
BSD 3-Clause "New" or "Revised" License
16 stars 1 forks source link

fclose called on unallocated object 'socket' #6

Open RonaldPhilipsen opened 1 year ago

RonaldPhilipsen commented 1 year ago

When trying to build the project from source I get this error on fedora 38.

$ cd build
$ cmake ..
-- The C compiler identification is GNU 13.1.1
-- The CXX compiler identification is GNU 13.1.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
-- Found PkgConfig: /usr/bin/pkg-config (found version "1.8.0") 
-- Checking for one of the modules 'libevdev'
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- CMake is using GNUCC. Verbose flags are activated.
-- [OPTION] Debug/error messages do not display source file and line.
CMake Warning (dev) at CMakeLists.txt:106 (set):
  implicitly converting 'INTEGER' to 'STRING' type.
This warning is for project developers.  Use -Wno-dev to suppress it.

-- [OPTION] Axis options can contain up to 64 characters (name + params).
-- [OPTION] Virtual devices' names are prefixed by 'relabsd:'.
-- Configuring done (1.1s)
-- Generating done (0.0s)
-- Build files have been written to: /home/user/Source/relabsd/build
$ make
[  4%] Building C object CMakeFiles/relabsd.dir/src/client.c.o
/home/user/Source/relabsd/src/client.c: In function ‘receive_reply’:
/home/user/Source/relabsd/src/client.c:162:11: error: ‘fclose’ called on unallocated object ‘socket’ [-Werror=free-nonheap-object]
  162 |    (void) fclose(socket);
      |           ^~~~~~~~~~~~~~
/home/user/Source/relabsd/src/client.c:158:9: note: declared here
  158 |    FILE socket [const restrict static 1]
      |    ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[2]: *** [CMakeFiles/relabsd.dir/build.make:76: CMakeFiles/relabsd.dir/src/client.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/relabsd.dir/all] Error 2
nsensfel commented 1 year ago

Thank you for the report. I'll have a look. I believe this is linked to this GCC debatable decision regarding when to warn and when not to. I need to figure out how to remove that warning, as it is unwarranted in this case. In the meantime, the project can be compiled by removing -Werror on line 31 of CMakeLists.txt (https://github.com/nsensfel/relabsd/blob/master/CMakeLists.txt).

RonaldPhilipsen commented 1 year ago

Sorry for the royally late reply, this worked like a charm