[Proj] Code style in Proj

Kurt Schwehr schwehr at gmail.com
Sun Apr 22 06:08:43 PDT 2018


Totally missed that lp.lam assignment!  Next iteration... also tried to add
a const to the lp arg.

https://godbolt.org/g/b4FUf7

And as for the static analize, try to imagine that this is being done on a
much more complicated function, because, yes, if a static analyzer didn't
get this function, it's pretty much useless.

On Sun, Apr 22, 2018 at 5:26 AM, Even Rouault <even.rouault at spatialys.com>
wrote:

> On samedi 21 avril 2018 15:46:22 CEST Kurt Schwehr wrote:
>
> > Hi all,
>
> >
>
> > I've been thinking about what is possible with the Proj code base with an
>
> > assumption that the code must be C89/C90 compatible. I played around for
> a
>
> > few in godbolt with PJ_august.c (because it's small) and ended up with
>
> > this. I tried to be aggressive as I could. I think my modified version is
>
> > likely to be more static analyzer friendly.
>
>
>
> I hope they are intelligent enough to make sense of the original code ;-)
>
>
>
> > - Don't have assignments hidden inside expressions
>
>
>
> Definitely +1 on this !
>
>
>
> To avoid the modification of lp.lam in the cos(),
>
>
>
> > const double c = 1.0 + c1 * cos(lp.lam *= .5);
>
> > const double x1 = sin(lp.lam) * c1 / c;
>
>
>
> this part could also be re-written, as
>
>
>
> const double half_lam = 0.5 * lp.lam;
>
> const double c = 1.0 + c1 * cos(half_lam);
>
> const double x1 = sin(half_lam) * c1 / c;
>
>
>
>
>
>
>
> --
>
> Spatialys - Geospatial professional services
>
> http://www.spatialys.com
>



-- 
--
http://schwehr.org
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/proj/attachments/20180422/bd7843bb/attachment.html>


More information about the Proj mailing list