[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [avrdude-dev] Fix warnings patch
From: |
E. Weddington |
Subject: |
Re: [avrdude-dev] Fix warnings patch |
Date: |
Thu, 28 Aug 2003 19:14:26 GMT |
<snip>
> Looks fine to me, Eric. The only delta I'm not sure
about is the one
> to stk500.c. Does that relate to the code the Joerg
added for setting
> STK500 operational parameters? I presume that if Joerg
has any
> questions about that he can comment.
>
The change to stk500.c affects stk500_set_fosc(). The diff
on it looks huge and ungainly mostly due to the effects of
indenting a large block of lines.
The original was something like (irrelavent parts ommitted)
[sorry for gratuitous wrapping]:
static int stk500_set_fosc(PROGRAMMER * pgm, double v)
{
//...
unsigned prescale, cmatch, fosc;
// ...
if (v <= 0.0) {
prescale = cmatch = 0;
goto setclock;
}
// big code block that sets prescale and cmatch
setclock:
if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE,
prescale)) != 0
|| (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH,
cmatch)) != 0)
return rc;
return 0;
}
Then it gets transformed to:
static int stk500_set_fosc(PROGRAMMER * pgm, double v)
{
// ...
unsigned prescale, cmatch, fosc;
// ...
prescale = cmatch = 0;
if (v > 0.0) {
// big code block that sets prescale and cmatch
}
if ((rc = stk500_setparm(pgm, Parm_STK_OSC_PSCALE,
prescale)) != 0
|| (rc = stk500_setparm(pgm, Parm_STK_OSC_CMATCH,
cmatch)) != 0)
return rc;
return 0;
}
It gets rid of 2 warnings about "variable may not be
initialized" for prescale and cmatch, and has the added
benefit of getting rid of a goto.
It's a little easier to see when patched. :-/
HTH,
Eric
Re: [avrdude-dev] Fix warnings patch,
E. Weddington <=
Re: [avrdude-dev] Fix warnings patch, E. Weddington, 2003/08/28
Re: [avrdude-dev] Fix warnings patch, eric, 2003/08/28
Re: [avrdude-dev] Fix warnings patch, E. Weddington, 2003/08/28
Re: [avrdude-dev] Fix warnings patch, E. Weddington, 2003/08/28
Re: [avrdude-dev] Fix warnings patch, E. Weddington, 2003/08/29