Skip to content
  • Philippe Mathieu-Daudé's avatar
    1cb169b2
    hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer · 1cb169b2
    Philippe Mathieu-Daudé authored
    
    
    Fix integer handling issues handling issue reported by Coverity:
    
      hw/ssi/npcm7xx_fiu.c: 162 in npcm7xx_fiu_flash_read()
      >>>     CID 1432730:  Integer handling issues  (NEGATIVE_RETURNS)
      >>>     "npcm7xx_fiu_cs_index(fiu, f)" is passed to a parameter that cannot be negative.
      162         npcm7xx_fiu_select(fiu, npcm7xx_fiu_cs_index(fiu, f));
    
      hw/ssi/npcm7xx_fiu.c: 221 in npcm7xx_fiu_flash_write()
      218         cs_id = npcm7xx_fiu_cs_index(fiu, f);
      219         trace_npcm7xx_fiu_flash_write(DEVICE(fiu)->canonical_path, cs_id, addr,
      220                                       size, v);
      >>>     CID 1432729:  Integer handling issues  (NEGATIVE_RETURNS)
      >>>     "cs_id" is passed to a parameter that cannot be negative.
      221         npcm7xx_fiu_select(fiu, cs_id);
    
    Since the index of the flash can not be negative, return an
    unsigned type.
    
    Reported-by: Coverity (CID 1432729 & 1432730: NEGATIVE_RETURNS)
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarHavard Skinnemoen <hskinnemoen@google.com>
    Message-id: 20200919132435.310527-1-f4bug@amsat.org
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
    1cb169b2
    hw/ssi/npcm7xx_fiu: Fix handling of unsigned integer
    Philippe Mathieu-Daudé authored
    
    
    Fix integer handling issues handling issue reported by Coverity:
    
      hw/ssi/npcm7xx_fiu.c: 162 in npcm7xx_fiu_flash_read()
      >>>     CID 1432730:  Integer handling issues  (NEGATIVE_RETURNS)
      >>>     "npcm7xx_fiu_cs_index(fiu, f)" is passed to a parameter that cannot be negative.
      162         npcm7xx_fiu_select(fiu, npcm7xx_fiu_cs_index(fiu, f));
    
      hw/ssi/npcm7xx_fiu.c: 221 in npcm7xx_fiu_flash_write()
      218         cs_id = npcm7xx_fiu_cs_index(fiu, f);
      219         trace_npcm7xx_fiu_flash_write(DEVICE(fiu)->canonical_path, cs_id, addr,
      220                                       size, v);
      >>>     CID 1432729:  Integer handling issues  (NEGATIVE_RETURNS)
      >>>     "cs_id" is passed to a parameter that cannot be negative.
      221         npcm7xx_fiu_select(fiu, cs_id);
    
    Since the index of the flash can not be negative, return an
    unsigned type.
    
    Reported-by: Coverity (CID 1432729 & 1432730: NEGATIVE_RETURNS)
    Signed-off-by: default avatarPhilippe Mathieu-Daudé <f4bug@amsat.org>
    Reviewed-by: default avatarHavard Skinnemoen <hskinnemoen@google.com>
    Message-id: 20200919132435.310527-1-f4bug@amsat.org
    Signed-off-by: default avatarPeter Maydell <peter.maydell@linaro.org>
Loading