[LiSA-Devel] FIXME output

Radu Rendec radu.rendec at mindbit.ro
Tue Mar 12 11:37:50 EET 2013


On Tue, 2013-03-12 at 10:46 +0200, Ionut Nicu wrote:
> On Tue, 2013-03-12 at 10:26 +0200, Andreea-Cristina Hodea wrote:
> > There are a lot of FIXME output in different sources in userspace. Do
> > you refer to fixing the file descriptor (i.e. opening a file
> > descriptor with ctx->out_open(ctx, some_val) instead of calling
> > fprintf(stdout,...)) or fixing the message sent to stdout/stderr? As a
> > reference file, see cli/command/exec.c, function cmd_cl_mac_addr_t,
> > line 249
> It's been quite some time since we wrote that code, but I think you're
> right, the FIXMEs were for changing the code to use ctx->out_open()
> instead of using fprintf(stdout, ...) directly.

The FIXMEs are definitely for the way we're doing the output, and not
for the message contents.

However, in this particular case, I think it's better and easier to use
CLI_EX_WARNING and EX_STATUS_REASON() and let the rlshell module handle
the actual output, since you only have to print an error message.

The ctx->out_open() mechanism is meant for commands that actually need
to do a lot of output (like "show mac-address-table", for instance). The
reason why it's not wise to print to stdout directly is beacause command
output can be directed to a pager and/or filtered, and this is done
transparently to the command handler. Therefore command handlers are
required to call ctx->out_open() and there is no guarantee that the
stream they get in return will be stdout.

Radu




More information about the LiSA-Devel mailing list