[PATCH 5/5] Limit the scope of gasidx in add_plan_to_notes

Tomaz Canabrava tcanabrava at kde.org
Thu Jul 10 14:37:19 PDT 2014


taking that patch we can clear a bunch of code from the for_each_dive
macro by declaring int i and struct dive *dive on it too.

On Thu, Jul 10, 2014 at 5:36 PM, Dirk Hohndel <dirk at hohndel.org> wrote:
> On Thu, Jul 10, 2014 at 10:34:24PM +0200, Anton Lundin wrote:
>> On 10 July, 2014 - Dirk Hohndel wrote:
>>
>> > On Thu, Jul 10, 2014 at 10:11:46PM +0200, Anton Lundin wrote:
>> > > Signed-off-by: Anton Lundin <glance at acc.umu.se>
>> > > ---
>> > >  planner.c | 4 ++--
>> > >  1 file changed, 2 insertions(+), 2 deletions(-)
>> > >
>> > > diff --git a/planner.c b/planner.c
>> > > index 785db4d..5cd9ba9 100644
>> > > --- a/planner.c
>> > > +++ b/planner.c
>> > > @@ -518,7 +518,7 @@ static unsigned int *sort_stops(int *dstops, int dnr, struct gaschanges *gstops,
>> > >  static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool show_disclaimer)
>> > >  {
>> > >   char buffer[20000], temp[1000];
>> > > - int len, gasidx, lastdepth = 0, lasttime = 0;
>> > > + int len, lastdepth = 0, lasttime = 0;
>> > >   struct divedatapoint *dp = diveplan->dp;
>> > >   bool gaschange = !plan_verbatim;
>> > >   struct divedatapoint *nextdp = NULL;
>> > > @@ -637,7 +637,7 @@ static void add_plan_to_notes(struct diveplan *diveplan, struct dive *dive, bool
>> > >
>> > >   snprintf(temp, sizeof(temp), "%s", translate("gettextFromC", "Gas consumption:"));
>> > >   len += snprintf(buffer + len, sizeof(buffer) - len, "</tbody></table></div><div><br>%s<br>", temp);
>> > > - for (gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
>> > > + for (int gasidx = 0; gasidx < MAX_CYLINDERS; gasidx++) {
>> >
>> > IIRC we don't want to use this in C files because some older C compilers
>> > throw up with it...
>> >
>>
>> I checked, and we already do, for windows atleast =)
>>
>> windows.c:            for (int i = 0; i < len; i++)
>
> He. And here I thought it was MSVC that had problems with it...
> Since clang on Apple and both gcc and clang on Linux are fine, I guess
> I'll take the patch :-)
>
> /D
> _______________________________________________
> subsurface mailing list
> subsurface at hohndel.org
> http://lists.hohndel.org/cgi-bin/mailman/listinfo/subsurface


More information about the subsurface mailing list