From 8ec76d7ed79a7bfa1e030f7f5f6a7c26a8dbc13a Mon Sep 17 00:00:00 2001 From: Jean Delvare Date: Fri, 10 Nov 2006 09:38:56 +0000 Subject: [PATCH] prog/eepromer/eepromer: Enable warnings, and fix most of them. The code of this program was really ugly (and still is), its author should be ashamed. git-svn-id: http://lm-sensors.org/svn/lm-sensors/trunk@4231 7894878c-1315-0410-8ee3-d5d059ff63e0 --- CHANGES | 1 + prog/eepromer/Makefile | 2 +- prog/eepromer/eepromer.c | 51 ++++++++++------------------------------ 3 files changed, 15 insertions(+), 39 deletions(-) diff --git a/CHANGES b/CHANGES index 249dd128..fb7aa1b0 100644 --- a/CHANGES +++ b/CHANGES @@ -12,6 +12,7 @@ SVN HEAD Man page i2cdetect.8: Describe the output convention Man page sensors.1: Update (option -c) and clean up Module icspll: Delete. It was useless and dangerous. + Program eepromer: Fix loads of warnings Program i2cdetect: Make the output clearer Program py-smbus: New! Python i2c-dev bindings (prog/py-smbus) Program sensord: Add pc87247 support (fans only) diff --git a/prog/eepromer/Makefile b/prog/eepromer/Makefile index 514be05d..2f6a9826 100644 --- a/prog/eepromer/Makefile +++ b/prog/eepromer/Makefile @@ -1,6 +1,6 @@ #eepromer Makefile -CFLAGS = -O2 -I../../kernel/include +CFLAGS = -O2 -I../../kernel/include -Wall all: eepromer eeprom eeprog diff --git a/prog/eepromer/eepromer.c b/prog/eepromer/eepromer.c index 60d6ca0d..8273b26c 100644 --- a/prog/eepromer/eepromer.c +++ b/prog/eepromer/eepromer.c @@ -35,6 +35,8 @@ void help(void); int init(char *device,int addr); int content_write(int file, int addr); int content_read(int file, int addr); +int inode_write(int file, int dev_addr, int lenght); +int inode_read(int file, int dev_addr, void *p_inode); void pheader(int file, int addr); void erase(int file,int addr,int eeprom_size); void made_address(int addr,unsigned char *buf); @@ -78,22 +80,10 @@ void help(void) int main(int argc, char *argv[]){ - int i,j,res,i2cbus,address,size,file; - struct i2c_msg *msgs,msg[2]; - int nmsgs,addr; - char *pbuf; + int i, file, addr; int action; //in this variable will be (-r,-w,-e) char device[45]; int force; - - - - struct i2c_ioctl_rdwr_data { - - struct i2c_msg *msgs; /* ptr to array of simple messages */ - int nmsgs; /* number of messages to exchange */ - } msgst,*pmsgst; - p_ind=&m_ind; force=0; @@ -228,8 +218,6 @@ int block_write(int file,int dev_addr,int eeprom_addr,unsigned char *buf,int len unsigned char buff[2]; struct i2c_msg msg[2]; - char *pbuff; - int j; struct i2c_ioctl_rdwr_data { @@ -287,12 +275,8 @@ int block_write(int file,int dev_addr,int eeprom_addr,unsigned char *buf,int len int block_read(int file,int dev_addr,int eeprom_addr,unsigned char *buf){ - - int ln,i,j; - - + int ln; char buff[2]; //={0x0,0x0}; - char pom; struct i2c_msg msg[2]; @@ -328,7 +312,7 @@ int block_read(int file,int dev_addr,int eeprom_addr,unsigned char *buf){ - if (ln=ioctl(file,I2C_RDWR,&msgst) < 0){ + if ((ln = ioctl(file, I2C_RDWR, &msgst)) < 0) { fprintf(stderr, "Error: Read error:%d\n",ln); @@ -356,9 +340,7 @@ int block_read(int file,int dev_addr,int eeprom_addr,unsigned char *buf){ void made_address(int addr,unsigned char *buf){ - - int i,j,k; - char a; + int k; //addr = addr & 0xFFFF; /*odstranim nepoterbne bity*/ @@ -414,7 +396,7 @@ int content_write(int file, int addr){ unsigned char buf[MAX_BLK_SIZE]; unsigned char pom; - int dat,i,j,k,delka,addr_cnt ; + int i, j, k, delka, addr_cnt; delka=0; addr_cnt=HEAD_SIZE; @@ -469,7 +451,7 @@ int content_write(int file, int addr){ } - return; + return 0; } @@ -477,8 +459,7 @@ int content_write(int file, int addr){ int content_read(int file, int addr){ unsigned char buf[MAX_BLK_SIZE]; - unsigned char pom; - int dat,i,j,k,delka,addr_cnt ; + int i, j, k, delka; delka=0; k=0; @@ -513,7 +494,7 @@ int content_read(int file, int addr){ } - return; + return 0; } @@ -522,8 +503,7 @@ int content_read(int file, int addr){ void erase(int file, int addr,int eeprom_size){ unsigned char buf[MAX_BLK_SIZE]; - unsigned char pom; - int dat,i,j,k,delka,addr_cnt ; + int i, j, k, delka; delka=0; k=0; @@ -602,8 +582,6 @@ int inode_write(int file,int dev_addr,int lenght){ unsigned char buff[2]; struct i2c_msg msg[2]; - char *pbuff; - int j; struct i2c_ioctl_rdwr_data { @@ -661,11 +639,8 @@ int inode_read(int file,int dev_addr,void *p_inode ){ #define POK 32 - int ln,i; - - + int ln; char buff[2]; //={0x0,0x0}; - char pom; struct i2c_msg msg[2]; @@ -698,7 +673,7 @@ int inode_read(int file,int dev_addr,void *p_inode ){ msgst.nmsgs = 2; - if (ln=ioctl(file,I2C_RDWR,&msgst) < 0){ + if ((ln = ioctl(file, I2C_RDWR, &msgst)) < 0) { fprintf(stderr, "Error: Read error:%d\n",ln);