SMBUS Library, warning, remove?

  1. this thread is as here: http://forum.arduino.cc/index.php?topic=340794.0
    Started separate thread since I want to know how to remove warnings.

  2. I am using this SMBUS library for timeout functionality:
    http://playground.arduino.cc/Main/SoftwareI2CLibrary

  3. However it has some warnings:

SoftI2CMaster.h:269:7: warning: unused parameter 'addr' [-Wunused-parameter]
 bool  i2c_start(uint8_t addr)
       ^
SoftI2CMaster.h:287:7: warning: unused parameter 'addr' [-Wunused-parameter]
 bool  i2c_rep_start(uint8_t addr)
       ^
SoftI2CMaster.h:312:7: warning: unused parameter 'addr' [-Wunused-parameter]
 void  i2c_start_wait(uint8_t addr)
       ^
SoftI2CMaster.h:359:6: warning: unused parameter 'value' [-Wunused-parameter]
 bool i2c_write(uint8_t value)
      ^
SoftI2CMaster.h:436:9: warning: unused parameter 'last' [-Wunused-parameter]
 uint8_t i2c_read(bool last)
    1. I think to remove these warning, since these are warning of unused varaibles in function so
      writing this, will remove the warning.I am not sure if this is right way to do.
      if(unused_var){}
  1. Attached updated files are in post#2 here:
    http://forum.arduino.cc/index.php?topic=340794.0

    1. I think to remove these warning, since these are warning of unused varaibles in function so
      writing this, will remove the warning.I am not sure if this is right way to do.
      if(unused_var){}

Adding some useless code to use an otherwise unused variable does not make sense. Get rid of the unused variables.

  1. Actually those vars are accessed via assembly routines defined inside. Below is code of one function:
bool  i2c_start(uint8_t addr)
{
  __asm__ __volatile__ 
    (
#if I2C_NOINTERRUPT
     " cli                              ;clear IRQ bit \n\t"
#endif
     " sbis     %[SCLIN],%[SCLPIN]      ;check for clock stretching slave\n\t"
     " rcall    ass_i2c_wait_scl_high   ;wait until SCL=H\n\t" 
     " sbi      %[SDADDR],%[SDAPIN]     ;force SDA low  \n\t" 
     " rcall    ass_i2c_delay_half      ;wait T/2 \n\t"
     " rcall    ass_i2c_write           ;now write address \n\t"
     " ret"
     : : [SDADDR] "I"  (SDA_DDR), [SDAPIN] "I" (SDA_PIN),
       [SCLIN] "I" (SCL_IN),[SCLPIN] "I" (SCL_PIN)); 
  return true; // we never return here!
}
  1. As can be seen var addr is accessed via assembly function. (i don't know how it happened, but code works). Also writer had added last statement "return true", to fool the compiler so it don't generate any warning. however code return in assembly part inside.

  2. On compiling there is warning that addr is unused. So I think adding another statement before
    return function will remove the warning.
    if(addr){}

  3. However I didn't made any changes since I didn't read its license terms till now.