dfskoll / rp-pppoe

Public repository for RP-PPPoE PPPoE client and server software
https://dianne.skoll.ca/projects/rp-pppoe/
47 stars 15 forks source link

Compilation Error :control_socket_handle_command #20

Closed PQFitz closed 1 year ago

PQFitz commented 1 year ago

Hello, brother

OS: Docker Centos7

cd rp-pppoe-master/src ./configure --enable-plugin make

Here are the errors encountered

gcc 4.8.5 control_socket.c: In function 'control_socket_handle_command': control_socket.c:58:2: error: parameter name omitted void* _subs, void*) ^ control_socket.c:67:2: error: 'for' loop initial declarations are only allowed in C99 mode for (ControlCommand *i = subs; i->command; ++i) { ^ control_socket.c:67:2: note: use option -std=c99 or -std=gnu99 to compile your code control_socket.c:89:2: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = 0; i < argi; ++i) { ^ control_socket.c:96:5: error: 'for' loop initial declarations are only allowed in C99 mode for (ControlCommand *i = subs; i->command; ++i) { ^ control_socket.c: In function 'control_socket_cleanup_client': control_socket.c:109:5: error: 'for' loop initial declarations are only allowed in C99 mode for (int i = client->ctxi; i >= 0; --i) { ^ control_socket.c: In function 'control_socket_push_context': control_socket.c:121:5: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration] ClientContext *t = reallocarray(client->context, client->ctxi + 2, sizeof(*client->context)); ^ control_socket.c:121:24: warning: initialization makes pointer from integer without a cast [enabled by default] ClientContext *t = reallocarray(client->context, client->ctxi + 2, sizeof(*client->context)); ^ make: *** [control_socket.o] Error 1

gcc 9.3.1

cc -g -O2 -fno-strict-aliasing -Wall -Wstrict-prototypes '-DPPPOE_PATH="/usr/sbin/pppoe"' '-DPPPD_PATH="/usr/local/sbin/pppd"' '-DPLUGIN_PATH="/etc/ppp/plugins/rp-pppoe.so"' '-DPPPOE_SERVER_OPTIONS="/etc/ppp/pppoe-server-options"' -Ilibevent -c -o control_socket.o control_socket.c control_socket.c: In function 'control_socket_handle_command': control_socket.c:58:15: error: parameter name omitted 58 | void* _subs, void*) | ^~~~~ control_socket.c: In function 'control_socket_push_context': control_socket.c:121:24: warning: implicit declaration of function 'reallocarray' [-Wimplicit-function-declaration] 121 | ClientContext *t = reallocarray(client->context, client->ctxi + 2, sizeof(*client->context)); | ^~~~~~~~~~~~ control_socket.c:121:24: warning: initialization of 'ClientContext *' {aka 'struct ClientContext *'} from 'int' makes pointer from integer without a cast [-Wint-conversion] make: *** [control_socket.o] Error 1

dfskoll commented 1 year ago

@jkroonza ... can you rework your changes to be compatible with older C compilers?

dfskoll commented 1 year ago

Specifically, the rp-pppoe style doesn't allow for initializers in for loops.

dfskoll commented 1 year ago

@jkroonza Also, we need to provide our own implementation of reallocarray. It seems that the version of libc that ships with CentOS 7 lacks it (or maybe we just need to define _GNU_SOURCE for that version?)

dfskoll commented 1 year ago

@jkroonza and @PQFitz

I have created a branch at https://github.com/dfskoll/rp-pppoe/tree/fix-compilation-on-centos-7 and a PR at https://github.com/dfskoll/rp-pppoe/pull/21

@PQFitz, please let me know if the branch works for you. @jkroonza, could you review the PR for sanity-checking?

Regards,

Dianne.

jkroonza commented 1 year ago

Looks good to me, with two minor recommendations I commented in the PR.

jkroonza commented 1 year ago

I note you merged, so believe this can be closed.