b.a.t.m.a.n.lists.open-mesh.org archive mirror
 help / color / mirror / Atom feed
From: "Linus Lüssing" <linus.luessing@web.de>
To: The list for a Better Approach To Mobile Ad-hoc Networking
	<b.a.t.m.a.n@lists.open-mesh.org>
Subject: Re: [B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators
Date: Thu, 1 Jul 2010 00:42:43 +0200	[thread overview]
Message-ID: <20100630224243.GA22928@Sellars> (raw)
In-Reply-To: <201006302135.50499.lindner_marek@yahoo.de>

On Wed, Jun 30, 2010 at 09:35:49PM +0200, Marek Lindner wrote:
> On Wednesday 30 June 2010 20:03:13 Linus Lüssing wrote:
> > +	char msecs_buff[4];
> > +	memset(msecs_buff, '0', sizeof(msecs_buff));
> > +	msecs_buff[3] = '\0';
>
> Shouldn't a simple 
> memset(msecs_buff, 0, sizeof(msecs_buff));
> be enough ?
The intention of the msecs_buff was, to do some zeroed alignment
which is not possible with sscanf automatically (so without it, a
-t 0.99 were converted to 99ms instead of 990).
The last one is is for just marking the end of the string (note,
'0' != '\0' ;) ).
> 
> 
> 
> > +			if (sscanf(optarg, "%3d.%3s", &orig_timeout_secs,
> > +			else if (sscanf(optarg, "%3d", &orig_timeout_secs) == 1) { ; }
> > +			else {
> 
> I don't quite understand the sense of the "else if" here. You could also 
> write:
> else if (sscanf(optarg, "%3d", &orig_timeout_secs) != 1)
Yep, you're right, I guess I was thinking too 'imperative' here
:D.
> and write no else block but I don't see why 1 second should be accepted and 
> nothing else ?
Nope, sscanf returns the number of succesfully scanned values, so
the 1 is not actually 1sec. But you're right, it can't read more
than 1 with only one %d in it anyway, so checking sscanf() < 1
would be fine too.

Anyway, I guess you're right, that integer arithmetics was pretty
much like using a slegdehammer to crack a nut in this case :).

See new patches for a less 'creative' approach :P.
> 
> Regards,
> Marek
> 

Cheers, Linus

  reply	other threads:[~2010-06-30 22:42 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-30 18:03 [B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators Linus Lüssing
2010-06-30 18:03 ` [B.A.T.M.A.N.] [PATCH] batctl: Add an optional interval for watch-mode Linus Lüssing
2010-06-30 19:35 ` [B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators Marek Lindner
2010-06-30 22:42   ` Linus Lüssing [this message]
2010-06-30 22:29 ` [B.A.T.M.A.N.] Simplifying new interval settings features in batctl Linus Lüssing
2010-06-30 22:29 ` [B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators Linus Lüssing
2010-07-01 15:33   ` Marek Lindner
2010-06-30 22:29 ` [B.A.T.M.A.N.] [PATCH] batctl: Add an optional interval for watch-mode Linus Lüssing
2010-07-02  0:10 [B.A.T.M.A.N.] batctl: timeout + refresh-interval, v3 Linus Lüssing
2010-07-02  0:10 ` [B.A.T.M.A.N.] [PATCH] batctl: Add timeout filtering option for originators Linus Lüssing

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=20100630224243.GA22928@Sellars \
    --to=linus.luessing@web.de \
    --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;
as well as URLs for NNTP newsgroup(s).