[collectd] [PATCH] utils_format_json: serialize nan and inf as null, as per JSON spec
octo at verplant.org
Thu Feb 4 13:03:29 CET 2010
On Thu, Feb 04, 2010 at 02:50:36AM -0800, Chris Buben wrote:
> With your proposed approach, won't we still get invalid json on a
> platform where isinf doesn't get defined?
In theory, yes.
> This doesn't matter in my particular experience (and never will, as on
> RHEL we'll always end up with isinf being defined), but it could be a
Well, since infinity isn't handled correctly in the network plugin
(among others) I think using it would cause some problems that would
need to be fixed first. But you're right, that's no excuse for emitting
invalid JSON ;)
> Assumption: in system header files, isnan and isinf are defined
> together -- so we get either both or neither. So with this
> assumption, seems like the only chance of the problem happening is the
> scenario when we end up with NAN_ZERO_ZERO (embedded platforms?), and
> isnan and isinf aren't defined?
I think that's a pretty safe assumption, yes.
> +# ifndef isinf
> +# define isinf(f) (!isnan (f) && isnan (f - f))
> +# endif /* !defined(isinf) */
Good idea :) I'll split that up into "isfinite" and "isinf" and then use
"isfinite" to check for normal, printable floating point values.
Florian octo Forster
Hacker in training
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Size: 189 bytes
Desc: Digital signature
Url : http://mailman.verplant.org/pipermail/collectd/attachments/20100204/21336695/attachment.pgp
More information about the collectd