[Nut-upsdev] gcc4 compiler warnings

Niels Baggesen nba at users.sourceforge.net
Fri Feb 10 08:53:51 UTC 2006


On Thu, Feb 09, 2006 at 04:36:00PM +0100, Niklas Edmundsson wrote:
> The following files emits warnings when compiled with gcc 4.0:
> al175.c
> bcmxcp_ser.c
> belkinunv.c
> cyberpower.c
> everups.c
> powercom.c
> solis.c

Now we are at it, could someone re-import the nitram driver with proper
line endings? My trusty gcc 2.95 gets hiccups from the continuationlines
with the added \r

Also, the al175 has some c++ style declarations in the middle of the
code blocks and some non-conforming %lf format specifiers, and gendb has
a csh style redirection that a true sh does not like. I have attached
patches for those.

/Niels

-- 
Niels Baggesen - @home - Århus - Denmark - nba at users.sourceforge.net
The purpose of computing is insight, not numbers   ---   R W Hamming
-------------- next part --------------
Index: drivers/al175.c
===================================================================
RCS file: /cvsroot/nut/nut/drivers/Attic/al175.c,v
retrieving revision 1.1.2.2
diff -u -r1.1.2.2 al175.c
--- drivers/al175.c	10 Oct 2005 19:43:54 -0000	1.1.2.2
+++ drivers/al175.c	8 Feb 2006 14:55:40 -0000
@@ -476,11 +476,12 @@
 static int comli_check_frame(const_raw_data_t f)
 {
 	int bcc;
+	byte_t *tail;
 
 	if (*f.begin!=STX)
 		return -1;
 
-	byte_t *tail = f.end - 2;
+	tail = f.end - 2;
 	if (tail <= f.begin)
 		return -1;
 
@@ -811,6 +812,7 @@
 static int recv_command_ack()
 {
 	int err;
+	raw_data_t ack;
 
 	/* 1:  STX  */
 	err = scan_for(STX);
@@ -818,7 +820,7 @@
 		return -1;
 
 
-	raw_data_t ack = raw_alloca(8);
+	ack = raw_alloca(8);
 	*(ack.end++) = STX;
 
  
@@ -857,14 +859,16 @@
 static int recv_register_data(io_head_t *io, raw_data_t *io_buf)
 {
 	int err;
+	raw_data_t reply_head;
+	raw_data_t reply;
 
 	/* 1:  STX  */
 	err = scan_for(STX);
 	if (err==-1)
 		return -1;
 
-	raw_data_t reply_head = raw_alloca(11);
-	*(reply_head.end++) = STX;
+	 reply_head = raw_alloca(11);
+	 *(reply_head.end++) = STX;
 
 
 	/* 2:  ID1 ID2 STAMP MSG_TYPE ADDR1 ADDR2 ADDR3 ADDR4 LEN1 LEN2 */
@@ -894,7 +898,7 @@
 #endif
 
 	/* 4:  allocate space for full reply and copy header there */
-	raw_data_t reply = raw_alloca(11/*head*/ + io->len/*data*/ + 2/*ETX BCC*/);
+	reply = raw_alloca(11/*head*/ + io->len/*data*/ + 2/*ETX BCC*/);
 
 	memcpy(reply.end, reply_head.begin, (reply_head.end - reply_head.begin));
 	reply.end += (reply_head.end - reply_head.begin);
@@ -969,6 +973,8 @@
 {
 	int err;
 	raw_data_t REQ_frame = raw_alloca(512);
+	raw_data_t rx_data;
+	io_head_t io;
 
 	al_prep_read_req(&REQ_frame, addr, count);
 
@@ -979,15 +985,10 @@
 		return -1;
 
 
-	raw_data_t rx_data = {
-		.buf	   = dst,
-		.buf_size  = count,
-
-		.begin	= dst,
-		.end	= dst
-	};
-
-	io_head_t io;
+	rx_data.buf	 = dst;
+	rx_data.buf_size = count;
+	rx_data.begin	 = dst;
+	rx_data.end	 = dst;
 
 	err = recv_register_data(&io, &rx_data);
 	if (err==-1)
@@ -1195,10 +1196,10 @@
 
 
 				// 0x4100   BATTERY VOLTAGE REF
-	dstate_setinfo("battery.voltage.nominal",	"%.2lf", d16(x4100+0));
+	dstate_setinfo("battery.voltage.nominal",	"%.2f", d16(x4100+0));
 
 				// 0x4110   BOOST VOLTAGE REF
-	dstate_setinfo("input.transfer.boost.low",	"%.2lf", d16(x4100+2));	// XXX: boost.high ?
+	dstate_setinfo("input.transfer.boost.low",	"%.2f", d16(x4100+2));	// XXX: boost.high ?
 
 				// 0x4120   HIGH BATT VOLT REF		XXX
 				// 0x4130   LOW  BATT VOLT REF		XXX
@@ -1206,13 +1207,13 @@
 				// 0x4180   FLOAT VOLTAGE		XXX
 				// 0x4190   BATT CURRENT
 	batt_current *= d16(x4180+2);
-	dstate_setinfo("battery.current",		"%.2lf", batt_current);
+	dstate_setinfo("battery.current",		"%.2f", batt_current);
 
 				// 0x41b0   LOAD CURRENT (output.current in NUT)
-	dstate_setinfo("output.current",		"%.2lf", d16(x4180+6));
+	dstate_setinfo("output.current",		"%.2f", d16(x4180+6));
 
 				// 0x4300   BATTERY TEMPERATURE
-	dstate_setinfo("battery.temperature",		"%.2lf", d16(x4300+0));
+	dstate_setinfo("battery.temperature",		"%.2f", d16(x4300+0));
 				
 
         status_commit();
Index: drivers/gendb
===================================================================
RCS file: /cvsroot/nut/nut/drivers/gendb,v
retrieving revision 1.1.1.1.8.1.2.6
diff -u -r1.1.1.1.8.1.2.6 gendb
--- drivers/gendb	19 Sep 2005 16:12:44 -0000	1.1.1.1.8.1.2.6
+++ drivers/gendb	8 Feb 2006 14:55:40 -0000
@@ -10,7 +10,7 @@
 
 MFDB=Makefile.drvbuild
 
-which gcc >& /dev/null
+which gcc >/dev/null 2>&1
 if [ $? != 0 ]; then
     echo "$0: gcc not found. Bailing out (and keeping $MFDB intact)."
     exit 1


More information about the Nut-upsdev mailing list