[OpenWrt-Devel] [PATCH] [ubus 1/2] cli: static keyword tweak

Zhao, Gang gang.zhao.42 at gmail.com
Fri Feb 26 03:26:07 EST 2016


On Fri, Feb 26, 2016 at 2:33 PM, John Crispin <blogic at openwrt.org> wrote:

> Description of what the patch does is missing
>
>         John
>
> On 26/02/2016 03:27, Zhao, Gang wrote:
> > Signed-off-by: Zhao, Gang <gang.zhao.42 at gmail.com>
> > ---
> >  cli.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/cli.c b/cli.c
> > index f3a041a..c476f35 100644
> > --- a/cli.c
> > +++ b/cli.c
> > @@ -127,7 +127,7 @@ static int ubus_cli_call(struct ubus_context *ctx,
> int argc, char **argv)
> >
> >  static int ubus_cli_listen(struct ubus_context *ctx, int argc, char
> **argv)
> >  {
> > -     static struct ubus_event_handler listener;
> > +     struct ubus_event_handler listener;
>

 Function ubus_cli_listen is called only once, and function uloop_run and
uloop_doen is called within this function, so I think it's not needed to
mark
struct ubus_event_handler listener static.

>       const char *event;
> >       int ret = 0;
> >
> > @@ -306,7 +306,7 @@ static int usage(const char *prog)
> >  }
> >
> >
> > -struct {
> > +static struct {
>
>       const char *name;
> >       int (*cb)(struct ubus_context *ctx, int argc, char **argv);
> >  } commands[] = {
>

Global struct commands is only used in this file, so it should be marked
static.


> > @@ -320,7 +320,7 @@ struct {
> >  int main(int argc, char **argv)
> >  {
> >       const char *progname, *ubus_socket = NULL;
> > -     static struct ubus_context *ctx;
> > +     struct ubus_context *ctx;
>

I think this struct is not needed to be marked static, since it's in the
main function.


> >       char *cmd;
> >       int ret = 0;
> >       int i, ch;
> >
> _______________________________________________
> openwrt-devel mailing list
> openwrt-devel at lists.openwrt.org
> https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/openwrt-devel/attachments/20160226/def092fc/attachment.htm>
-------------- next part --------------
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel


More information about the openwrt-devel mailing list