Page 1 of 1

cli only shows usage information

Posted: 25 Mar 2020, 12:45
by hardillb
I'm having a play with looking at session information and I'm having problems with the accel-cmd tool

With nearly any arguments and commands I always just get the usage instructions

Code: Select all

$ accel-cmd show sessions
Usage:	accel-cmd [-v] [-4] [-6] [-n] [-f FAMILY] [-H HOST] [-p PORT] [-t TIMEOUT] [COMMAND]
The only argument that gives anything different is -V which shows the version:

Code: Select all

accel-cmd -V
accel-cmd a4fe1168dda707a2836f6d74c7a6610645b20152
This looks to be a result of the

Code: Select all

default
block in the switch statement that processes the command line args.

Just checking I'm not doing anything stupid before I poke deeper into the code.

Re: cli only shows usage information

Posted: 25 Mar 2020, 20:46
by hardillb
OK, worked it out.

The return value from

Code: Select all

getopt_long
is meant to be an

Code: Select all

int
not a

Code: Select all

char
so the comparison to -1 is not working.

https://github.com/xebd/accel-ppp/blob/ ... cmd.c#L648

It even shows up in the warnings with the compiler on raspbian buster

Code: Select all

...
[ 99%] Building C object accel-cmd/CMakeFiles/accel-cmd.dir/accel_cmd.c.o
/home/pi/accel-ppp/accel-cmd/accel_cmd.c: In function ‘main’:
/home/pi/accel-ppp/accel-cmd/accel_cmd.c:652:29: warning: comparison is always true due to limited range of data type [-Wtype-limits]
         long_opts, &oindx)) != -1) {
                             ^~
[100%] Linking C executable accel-cmd
[100%] Built target accel-cmd
I'll stick a pull request in with the fix.

Re: cli only shows usage information

Posted: 25 Mar 2020, 22:35
by dimka88
Why this appears only on raspbian?

Re: cli only shows usage information

Posted: 25 Mar 2020, 22:47
by hardillb
Probably because Raspbian Buster is shipping with gcc version 8

gcc (Raspbian 8.3.0-6+rpi1) 8.3.0

On my Ubuntu 18.04.4 is still on version 7