[Nut-upsdev] patch: Fix [-Wunused-but-set-variable]
Regid Ichira
regid23 at yahoo.com
Mon Oct 3 14:45:07 UTC 2011
Description: Fix warning: variable set but not used
[-Wunused-but-set-variable]. bugs.debian.org/633756.
Related drivers were not tested.
Last-Update: Sat, 13 Aug 2011 14:04:48 +0300
Index: b/drivers/belkinunv.c
===================================================================
--- a/drivers/belkinunv.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/belkinunv.c 2011-08-17 00:26:30.000000000 +0300
@@ -1239,12 +1239,13 @@ int instcmd(const char *cmdname, const c
/* set a variable */
static int setvar(const char *varname, const char *val)
{
- int i, r;
+ int i;
if (!strcasecmp(varname, "input.sensitivity")) {
for (i=0; i<asize(voltsens); i++) {
if (!strcasecmp(val, voltsens[i])) {
- r = belkin_nut_write_int(REG_VOLTSENS, i);
+ belkin_nut_write_int(REG_VOLTSENS, i);
+ /* r = belkin_nut_write_int(REG_VOLTSENS, i); */
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
}
}
@@ -1261,13 +1262,13 @@ static int setvar(const char *varname, c
} else {
i=atoi(val);
}
- r = belkin_nut_write_int(REG_ALARMSTATUS, i);
+ belkin_nut_write_int(REG_ALARMSTATUS, i);
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
} else if (!strcasecmp(varname, "input.transfer.low")) {
- r = belkin_nut_write_int(REG_XFER_LO, atoi(val));
+ belkin_nut_write_int(REG_XFER_LO, atoi(val));
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
} else if (!strcasecmp(varname, "input.transfer.high")) {
- r = belkin_nut_write_int(REG_XFER_HI, atoi(val));
+ belkin_nut_write_int(REG_XFER_HI, atoi(val));
return STAT_SET_HANDLED; /* Future: failure if r==-1 */
}
Index: b/drivers/bestfcom.c
===================================================================
--- a/drivers/bestfcom.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/bestfcom.c 2011-08-17 00:23:22.000000000 +0300
@@ -260,13 +260,10 @@ void upsdrv_updateinfo(void)
double ampsout=0.0, vbatt=0.0, battpercent=0.0, loadpercent=0.0,
upstemp=0.0, acfreq=0.0;
- char date[9], time[9], tmp[32];
+ char tmp[32];
upsdebugx(3, "f response: %d %s", (int)strlen(fstring), fstring);
- date[0]='\0';
- time[0]='\0';
-
/* Inverter status. 0=off 1=on */
inverter = bcd2i(&fstring[16], 2);
Index: b/drivers/etapro.c
===================================================================
--- a/drivers/etapro.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/etapro.c 2011-08-17 00:23:22.000000000 +0300
@@ -213,7 +213,6 @@ upsdrv_initinfo(void)
void
upsdrv_updateinfo(void)
{
- char status[256];
int x, flags;
double utility, outvolt, battvolt, loadpct;
@@ -292,7 +291,6 @@ upsdrv_updateinfo(void)
status_init();
- status[0] = '\0';
if (!(flags & 0x02))
status_set("OFF");
else if (flags & 0x01)
Index: b/drivers/gamatronic.c
===================================================================
--- a/drivers/gamatronic.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/gamatronic.c 2011-08-17 00:23:22.000000000 +0300
@@ -248,7 +248,7 @@ void sec_poll ( int pollflag ) {
void upsdrv_initinfo(void)
{
- int msglen, e, v;
+ int msglen, v;
char *a,*p,avail_list[300];
/* find out which variables/commands this UPS supports */
@@ -264,7 +264,6 @@ void upsdrv_initinfo(void)
if (strlen(avail_list) == 0){
fatalx(EXIT_FAILURE, "No available variables found!");}
a = avail_list;
- e = 0;
while ((p = strtok(a, ",")) != NULL) {
a = NULL;
v = atoi(p);
Index: b/drivers/isbmex.c
===================================================================
--- a/drivers/isbmex.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/isbmex.c 2011-08-17 00:23:22.000000000 +0300
@@ -323,10 +323,10 @@ void upsdrv_shutdown(void)
* work, else:*/
/* fatalx(EXIT_FAILURE, "Shutdown only supported with the Generic Driver, type 6 and special cable"); */
/*fatalx(EXIT_FAILURE, "shutdown not supported");*/
- int i, ret;
+ int i;
for(i=0;i<=5;i++)
{
- ret = ser_send_char(upsfd, '#');
+ ser_send_char(upsfd, '#');
usleep(50000);
}
}
Index: b/drivers/metasys.c
===================================================================
--- a/drivers/metasys.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/metasys.c 2011-08-17 00:23:22.000000000 +0300
@@ -96,10 +96,9 @@ long int get_long(unsigned char *buffer)
void send_zeros(void) { /* send 100 times the value 0x00.....it seems to be used for resetting */
unsigned char buf[100]; /* the ups serial port */
- int i;
memset(buf, '\0', sizeof(buf));
- i = ser_send_buf(upsfd, buf, sizeof(buf));
+ ser_send_buf(upsfd, buf, sizeof(buf));
return;
}
Index: b/drivers/mge-shut.c
===================================================================
--- a/drivers/mge-shut.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/mge-shut.c 2011-08-17 00:23:22.000000000 +0300
@@ -796,7 +796,6 @@ int shut_packet_recv (u_char *Buf, int d
u_short Pos=0;
u_char Retry=0;
int recv;
- shut_data_t sdata;
upsdebugx (4, "entering shut_packet_recv (%i)", datalen);
@@ -804,7 +803,6 @@ int shut_packet_recv (u_char *Buf, int d
{
if(serial_read (DEFAULT_TIMEOUT, &Start[0]) >= 0)
{
- sdata.shut_pkt.bType = Start[0];
if(Start[0]==SHUT_SYNC)
{
upsdebugx (4, "received SYNC token");
@@ -819,7 +817,6 @@ int shut_packet_recv (u_char *Buf, int d
{
upsdebug_hex(3, "Receive", Start, 2);
Size=Start[1]&0x0F;
- sdata.shut_pkt.bLength = Size;
for(recv=0;recv<Size;recv++)
if(serial_read (DEFAULT_TIMEOUT, &Frame[recv]) < 0)
break;
Index: b/drivers/microdowell.c
===================================================================
--- a/drivers/microdowell.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/microdowell.c 2011-08-17 00:23:22.000000000 +0300
@@ -189,7 +189,7 @@ int CheckErrCode(unsigned char * Buff)
void SendCmdToSerial(unsigned char *Buff, int Len)
{
- int i, ret ;
+ int i;
unsigned char Tmp[20], Xor ;
Tmp[0] = STX_CHAR ;
@@ -204,9 +204,8 @@ void SendCmdToSerial(unsigned char *Buff
upsdebug_hex(4, "->UPS", Tmp, Len+3) ;
/* flush serial port */
- ret = ser_flush_in(upsfd, "", 0) ; /* empty input buffer */
-
- ret = ser_send_buf(upsfd, Tmp, Len+3) ; /* send data to the UPS */
+ ser_flush_in(upsfd, "", 0) ; /* empty input buffer */
+ ser_send_buf(upsfd, Tmp, Len+3) ; /* send data to the UPS */
}
Index: b/drivers/solis.c
===================================================================
--- a/drivers/solis.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/solis.c 2011-08-17 00:23:22.000000000 +0300
@@ -320,7 +320,6 @@ static void confups( void )
{
int i, chks = 0;
- unsigned char tst;
ConfigPack[0] = 0xCF;
ConfigPack[1] = ihour;
@@ -339,7 +338,10 @@ static void confups( void )
/* MSB zero */
ConfigPack[10] = ConfigPack[10] & (~(0x80));
- tst = ConfigPack[10];
+ /*
+ unsigned char tst;
+ tst = ConfigPack[10];
+ */
for(i=0; i < 11; i++)
chks = chks + ConfigPack[i];
@@ -355,9 +357,9 @@ static void confups( void )
static void prnInfo( void )
{
- int iw, sunday=0, monday=0, tuesday=0, wednesday=0, thursday=0, friday=0, saturday=0;
+ int sunday=0, monday=0, tuesday=0, wednesday=0, thursday=0, friday=0, saturday=0;
unsigned char dweek;
- iw = weekn;
+ /* int iw; iw = weekn; */
printf( UPS_DATE, Year, Month, Day );
printf( SYS_DATE, anon, mesn, dian, seman );
Index: b/drivers/libshut.c
===================================================================
--- a/drivers/libshut.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/libshut.c 2011-08-17 00:23:22.000000000 +0300
@@ -678,7 +678,6 @@ int shut_packet_recv(int upsfd, u_char *
u_short Pos=0;
u_char Retry=0;
int recv;
- shut_data_t sdata;
upsdebugx (4, "entering shut_packet_recv (%i)", datalen);
@@ -687,7 +686,6 @@ int shut_packet_recv(int upsfd, u_char *
/* if(serial_read (SHUT_TIMEOUT, &Start[0]) > 0) */
if(ser_get_char(upsfd, &Start[0], SHUT_TIMEOUT/1000, 0) > 0)
{
- sdata.shut_pkt.bType = Start[0];
if(Start[0]==SHUT_SYNC)
{
upsdebugx (4, "received SYNC token");
@@ -702,7 +700,6 @@ int shut_packet_recv(int upsfd, u_char *
{
upsdebug_hex(4, "Receive", Start, 2);
Size=Start[1]&0x0F;
- sdata.shut_pkt.bLength = Size;
for(recv=0;recv<Size;recv++)
{
/* if(serial_read (SHUT_TIMEOUT, &Frame[recv]) < 1) */
Index: b/drivers/rhino.c
===================================================================
--- a/drivers/rhino.c 2011-05-31 13:36:49.000000000 +0300
+++ b/drivers/rhino.c 2011-08-17 00:23:22.000000000 +0300
@@ -477,9 +477,8 @@ static int
send_command( int cmd )
{
- int i, chk, checksum=0, iend=18, sizes, ret, kount; /*, j, uc; */
+ int i, chk, checksum=0, iend=18, /* sizes=19, */ ret, kount; /*, j, uc; */
unsigned char ch, psend[19];
- sizes = 19;
checksum = 0;
/* mounting buffer to send */
@@ -645,16 +644,13 @@ static void getupdateinfo(void)
unsigned char temp[256];
int tam;
- int hours, mins;
-
/* time update */
time_t *tmt;
struct tm *now;
tmt = ( time_t * ) malloc( sizeof( time_t ) );
time( tmt );
now = localtime( tmt );
- hours = now->tm_hour;
- mins = now->tm_min;
+ /* int hours, mins; hours = now->tm_hour; mins = now->tm_min; */
temp[0] = 0; /* flush temp buffer */
tam = ser_get_buf_len(upsfd, temp, pacsize, 3, 0);
More information about the Nut-upsdev
mailing list