public inbox for b.a.t.m.a.n@lists.open-mesh.org
 help / color / mirror / Atom feed
From: Sven Eckelmann <sven@narfation.org>
To: Anatoliy <anatoliy.lapitskiy@gmail.com>
Cc: b.a.t.m.a.n@lists.open-mesh.org
Subject: Re: [B.A.T.M.A.N.] [PATCHv2] Added "--update-script" flag for specifying a command for running when new data piece is receviced.
Date: Fri, 13 Mar 2015 13:02:33 +0100	[thread overview]
Message-ID: <1501672.outaxq6BMD@bentobox> (raw)
In-Reply-To: <5502BBBF.2030801@gmail.com>

On Friday 13 March 2015 12:28:15 Anatoliy wrote:
[...]
> >> --- a/recv.c
> >> +++ b/recv.c
> >> @@ -40,7 +40,7 @@ static int finish_alfred_push_data(struct globals *globals,
> >>  				   struct ether_addr mac,
> >>  				   struct alfred_push_data_v0 *push)
> >>  {
> >> -	int len, data_len;
> >> +	int len, data_len, new_entry;
> >>  	struct alfred_data *data;
> >>  	struct dataset *dataset;
> >>  	uint8_t *pos;
> > Has anyone a better name for new_entry? I don't really like it because
> > it sounds to me like a variable that stores the pointer to a new object.
> "new_entry_created"?
> btw, it could be bool as it's just a flag. can I use <stdbool.h> from C99?

Yes, sounds good. I personally have nothing against bool.
(At least not at the moment)

[...]
> >> +
> >> +		if (globals->update_script && !list_empty(&globals->changed_data_types)) {
> >> +			/* call update script with list of datatypes_changed */
> >> +			char command[strlen(globals->update_script) + 7*globals->changed_data_type_count];
> > Please don't use variable length arrays.
> >
> > Please fix your spacing around operands.
> >
> > The calculation of the command length is complete bogus.
> Agree. it should be length of update_script + 4 * changed count (3 for data type as maximum is "255" + space) + 1 for NULL.
> I will add a comment about it.

Please don't forget the change of the datatype of data_type to really
have a range of 0-255.

I don't think the comment is important but we will see if it is helpful.

[...]
> >> +			int pid = fork();
> >> +			if (pid == 0) {
> >> +				system(command);
> > Why do you want to execute the command using the system shell? Maybe you
> > wanted to use something from the exec* family instead.
> In case if user will set shell script as "update-script" parameter, exec* won't work.
> Of course, I can add "sh", "-c" to exec* parameters, but what advantages this method will have then?

This was exactly the thing I wanted to know. If you really want to
support shell scripts then please update your manpage entry to
inform the user about this "feature". Otherwise he might
accidentally forget the required escaping or similar things.

Currently the manpage says that you can specify a path and not a
script which may be used to execute a file.

[...]
> >
> > Maybe there are more thing but I have to stop the review now.
> Again, thank you very much for review.
> Is there a link for code style used?

 * http://www.open-mesh.org/projects/open-mesh/wiki/Contribute#Submitting-patches
 * https://www.kernel.org/doc/Documentation/CodingStyle
 * the mood of the person reviewing the code

Kind regards,
	Sven

      reply	other threads:[~2015-03-13 12:02 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 11:06 [B.A.T.M.A.N.] [PATCHv2] Added "--update-script" flag for specifying a command for running when new data piece is receviced Anatoliy Lapitskiy
2015-03-13  8:35 ` Sven Eckelmann
2015-03-13 10:28   ` Anatoliy
2015-03-13 12:02     ` Sven Eckelmann [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1501672.outaxq6BMD@bentobox \
    --to=sven@narfation.org \
    --cc=anatoliy.lapitskiy@gmail.com \
    --cc=b.a.t.m.a.n@lists.open-mesh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox