From 6be83f469b3572b9bcaf79d4f67ec217a8102cc8 Mon Sep 17 00:00:00 2001 From: David Ward Date: Tue, 8 Mar 2022 19:00:00 -0500 Subject: [PATCH] Resolve compiler warnings about misleading indentation This change is targeted at specific lines of code reported by GCC or Clang as potentially causing unintended behavior. --- backend/dll.c | 4 ++-- backend/epsonds-net.c | 2 +- backend/genesys/genesys.cpp | 45 +++++++++++++++++++------------------ backend/genesys/low.cpp | 4 ++-- backend/ibm.c | 3 ++- backend/kodakaio.c | 8 +++---- backend/net.c | 4 ++-- backend/pixma/pixma_mp150.c | 2 +- backend/pixma/pixma_mp730.c | 8 +++---- backend/plustek-pp_motor.c | 10 +++++---- backend/plustek-pp_p12.c | 2 +- backend/plustek-pp_p48xx.c | 6 ++--- backend/ricoh.c | 3 ++- 13 files changed, 52 insertions(+), 49 deletions(-) diff --git a/backend/dll.c b/backend/dll.c index a3233e831..c644ba624 100644 --- a/backend/dll.c +++ b/backend/dll.c @@ -1068,7 +1068,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) char *full_name; int i, num_devs; size_t len; -#define ASSERT_SPACE(n) \ +#define ASSERT_SPACE(n) do \ { \ if (devlist_len + (n) > devlist_size) \ { \ @@ -1080,7 +1080,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) if (!devlist) \ return SANE_STATUS_NO_MEM; \ } \ - } + } while (0) DBG (3, "sane_get_devices\n"); diff --git a/backend/epsonds-net.c b/backend/epsonds-net.c index 4f4c1e267..0b185e4a9 100644 --- a/backend/epsonds-net.c +++ b/backend/epsonds-net.c @@ -513,7 +513,7 @@ fail: if (simple_poll) avahi_simple_poll_free(simple_poll); - DBG(10, "epsonds_searchDevices fin\n"); + DBG(10, "epsonds_searchDevices fin\n"); return result; } diff --git a/backend/genesys/genesys.cpp b/backend/genesys/genesys.cpp index 5818c206f..9a96e9daa 100644 --- a/backend/genesys/genesys.cpp +++ b/backend/genesys/genesys.cpp @@ -2847,7 +2847,8 @@ static void compute_averaged_planar(Genesys_Device * dev, const Genesys_Sensor& avgpixels = 15; /* LiDE80 packs shading data */ - if (dev->model->sensor_id != SensorId::CIS_CANON_LIDE_80) { + if (dev->model->sensor_id != SensorId::CIS_CANON_LIDE_80) + { factor=1; fill=avgpixels; } @@ -4883,28 +4884,28 @@ static void init_options(Genesys_Scanner* s) s->opt[OPT_POWER_SW].cap = SANE_CAP_INACTIVE; /* extra button */ - s->opt[OPT_EXTRA_SW].name = "extra"; - s->opt[OPT_EXTRA_SW].title = SANE_I18N("Extra button"); - s->opt[OPT_EXTRA_SW].desc = SANE_I18N("Extra button"); - s->opt[OPT_EXTRA_SW].type = SANE_TYPE_BOOL; - s->opt[OPT_EXTRA_SW].unit = SANE_UNIT_NONE; - if (model->buttons & GENESYS_HAS_EXTRA_SW) { - s->opt[OPT_EXTRA_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; - } else { - s->opt[OPT_EXTRA_SW].cap = SANE_CAP_INACTIVE; - } + s->opt[OPT_EXTRA_SW].name = "extra"; + s->opt[OPT_EXTRA_SW].title = SANE_I18N("Extra button"); + s->opt[OPT_EXTRA_SW].desc = SANE_I18N("Extra button"); + s->opt[OPT_EXTRA_SW].type = SANE_TYPE_BOOL; + s->opt[OPT_EXTRA_SW].unit = SANE_UNIT_NONE; + if (model->buttons & GENESYS_HAS_EXTRA_SW) + s->opt[OPT_EXTRA_SW].cap = + SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; + else + s->opt[OPT_EXTRA_SW].cap = SANE_CAP_INACTIVE; - // transparency/scan_film button - s->opt[OPT_TRANSP_SW].name = "transparency"; - s->opt[OPT_TRANSP_SW].title = SANE_I18N ("Transparency button"); - s->opt[OPT_TRANSP_SW].desc = SANE_I18N ("Transparency button"); - s->opt[OPT_TRANSP_SW].type = SANE_TYPE_BOOL; - s->opt[OPT_TRANSP_SW].unit = SANE_UNIT_NONE; - if (model->buttons & GENESYS_HAS_TRANSP_SW) { - s->opt[OPT_TRANSP_SW].cap = SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; - } else { - s->opt[OPT_TRANSP_SW].cap = SANE_CAP_INACTIVE; - } + /* transparency/scan_film button */ + s->opt[OPT_TRANSP_SW].name = "transparency"; + s->opt[OPT_TRANSP_SW].title = SANE_I18N ("Transparency button"); + s->opt[OPT_TRANSP_SW].desc = SANE_I18N ("Transparency button"); + s->opt[OPT_TRANSP_SW].type = SANE_TYPE_BOOL; + s->opt[OPT_TRANSP_SW].unit = SANE_UNIT_NONE; + if (model->buttons & GENESYS_HAS_TRANSP_SW) + s->opt[OPT_TRANSP_SW].cap = + SANE_CAP_SOFT_DETECT | SANE_CAP_HARD_SELECT | SANE_CAP_ADVANCED; + else + s->opt[OPT_TRANSP_SW].cap = SANE_CAP_INACTIVE; /* calibration needed */ s->opt[OPT_NEED_CALIBRATION_SW].name = "need-calibration"; diff --git a/backend/genesys/low.cpp b/backend/genesys/low.cpp index f9d247435..3ffc24a1d 100644 --- a/backend/genesys/low.cpp +++ b/backend/genesys/low.cpp @@ -360,8 +360,8 @@ void sanei_genesys_read_data_from_scanner(Genesys_Device* dev, std::uint8_t* dat { DBG_HELPER_ARGS(dbg, "size = %zu bytes", size); - if (size & 1) - DBG(DBG_info, "WARNING %s: odd number of bytes\n", __func__); + if (size & 1) + DBG(DBG_info, "WARNING %s: odd number of bytes\n", __func__); wait_until_has_valid_words(dev); diff --git a/backend/ibm.c b/backend/ibm.c index 688cdfb3d..ab5fbc940 100644 --- a/backend/ibm.c +++ b/backend/ibm.c @@ -568,7 +568,8 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) continue; /* ignore empty lines */ /* skip white space: */ - for (lp = line; isspace(*lp); ++lp); + for (lp = line; isspace(*lp); ++lp) + ; strcpy (devnam, lp); } fclose (fp); diff --git a/backend/kodakaio.c b/backend/kodakaio.c index fe83e270e..0241e2a84 100644 --- a/backend/kodakaio.c +++ b/backend/kodakaio.c @@ -716,7 +716,6 @@ That is probably if the scanner disconnected the network connection /* pollreply is -ve */ DBG(1, "net poll error\n"); *status = SANE_STATUS_IO_ERROR; - return read; } else if((fds[0].revents & POLLIN) && !(fds[0].revents & (POLLERR | POLLHUP | POLLNVAL))) { while (read < wanted) { @@ -733,12 +732,11 @@ That is probably if the scanner disconnected the network connection *status = SANE_STATUS_IO_ERROR; DBG(32, "net read %lu bytes:%x,%x,%x,%x,%x,%x,%x,%x\n",(unsigned long)read,buf[0],buf[1],buf[2],buf[3],buf[4],buf[5],buf[6],buf[7]); - - return read; } else DBG(1, "Unknown problem with poll\n"); - return read; + + return read; } @@ -2046,7 +2044,7 @@ open_scanner(KodakAio_Scanner *s) unsigned int model = 0; if (!split_scanner_name (s->hw->sane.name, IP, &model)) return SANE_STATUS_INVAL; - DBG(10, "split_scanner_name OK model=0x%x\n",model); + DBG(10, "split_scanner_name OK model=0x%x\n",model); /* normal with IP */ status = sanei_tcp_open(IP, 9101, &s->fd); /* (host,port,file pointer) */ diff --git a/backend/net.c b/backend/net.c index 7c4aae9d6..c659821cb 100644 --- a/backend/net.c +++ b/backend/net.c @@ -1201,7 +1201,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) char *full_name; int i, num_devs; size_t len; -#define ASSERT_SPACE(n) \ +#define ASSERT_SPACE(n) do \ { \ if (devlist_len + (n) > devlist_size) \ { \ @@ -1216,7 +1216,7 @@ sane_get_devices (const SANE_Device *** device_list, SANE_Bool local_only) return SANE_STATUS_NO_MEM; \ } \ } \ - } + } while (0) DBG (3, "sane_get_devices: local_only = %d\n", local_only); diff --git a/backend/pixma/pixma_mp150.c b/backend/pixma/pixma_mp150.c index d30516f4d..4b15c7368 100644 --- a/backend/pixma/pixma_mp150.c +++ b/backend/pixma/pixma_mp150.c @@ -1658,7 +1658,7 @@ mp150_finish_scan (pixma_t * s) else PDBG (pixma_dbg (4, "*mp150_finish_scan***** wait for next page from ADF *****\n")); - mp->state = state_idle; + mp->state = state_idle; /* fall through */ case state_idle: break; diff --git a/backend/pixma/pixma_mp730.c b/backend/pixma/pixma_mp730.c index 3b9d92afa..1fc9a7424 100644 --- a/backend/pixma/pixma_mp730.c +++ b/backend/pixma/pixma_mp730.c @@ -432,10 +432,10 @@ step1 (pixma_t * s) int tmo = 10; /* like Windows driver, 10 sec CCD calibration ? */ while (--tmo >= 0) { - error = handle_interrupt (s, 1000); \ - if (s->cancel) \ - return PIXMA_ECANCELED; \ - if (error != PIXMA_ECANCELED && error < 0) \ + error = handle_interrupt (s, 1000); + if (s->cancel) + return PIXMA_ECANCELED; + if (error != PIXMA_ECANCELED && error < 0) return error; PDBG (pixma_dbg (2, "CCD Calibration ends in %d sec.\n", tmo)); } diff --git a/backend/plustek-pp_motor.c b/backend/plustek-pp_motor.c index ac6d45857..b58e92df4 100644 --- a/backend/plustek-pp_motor.c +++ b/backend/plustek-pp_motor.c @@ -3128,7 +3128,7 @@ _LOC Bool MotorP96AheadToDarkArea( pScanData ps ) if((bDark < 0x80) || (wTotalLastLine==wTL)) { IOCmdRegisterToScanner( ps, ps->RegMotorControl, 0 ); - return _TRUE; + return _TRUE; } } #else @@ -3216,9 +3216,10 @@ _LOC void MotorP98003BackToHomeSensor( pScanData ps ) MiscStartTimer( &timer, _SECOND * 2 ); while(!(IOGetScanState( ps, _TRUE ) & _SCANSTATE_STOP) && - !MiscCheckTimer( &timer )); + !MiscCheckTimer( &timer )) + ; - _DODELAY( 1000UL ); + _DODELAY( 1000UL ); ps->AsicReg.RD_ModeControl = _ModeScan; @@ -3324,7 +3325,8 @@ _LOC void MotorP98003PositionYProc( pScanData ps, ULong steps) MiscStartTimer( &timer, _SECOND * 5 ); while(!(IOGetScanState( ps, _TRUE ) & _SCANSTATE_STOP) && - (!MiscCheckTimer( &timer ))); + !MiscCheckTimer( &timer )) + ; _DODELAY( 12 ); diff --git a/backend/plustek-pp_p12.c b/backend/plustek-pp_p12.c index e78c6826f..26566e5f4 100644 --- a/backend/plustek-pp_p12.c +++ b/backend/plustek-pp_p12.c @@ -472,7 +472,7 @@ static void p12Init98003( pScanData ps, Bool shading ) if( _AGFA_SCANNER == ps->Device.bPCBID ) ps->Device.bDACType = _DA_WOLFSON8141; - DBG( DBG_LOW, "PCB-ID=0x%02x, CCD-ID=0x%02x, DAC-TYPE=0x%02x\n", + DBG( DBG_LOW, "PCB-ID=0x%02x, CCD-ID=0x%02x, DAC-TYPE=0x%02x\n", ps->Device.bPCBID, ps->Device.bCCDID, ps->Device.bDACType ); p12InitiateComponentModel( ps ); diff --git a/backend/plustek-pp_p48xx.c b/backend/plustek-pp_p48xx.c index 3c2835714..9ae123948 100644 --- a/backend/plustek-pp_p48xx.c +++ b/backend/plustek-pp_p48xx.c @@ -613,9 +613,9 @@ static void p48xxSetGeneralRegister( pScanData ps ) if (ps->DataInf.xyPhyDpi.x <= 200) ps->AsicReg.RD_ScanControl |= _SCAN_1ST_AVERAGE; - DBG( DBG_LOW, "RD_ModeControl = 0x%02x\n", ps->AsicReg.RD_ModeControl ); - DBG( DBG_LOW, "RD_MotorControl = 0x%02x\n", ps->Asic96Reg.RD_MotorControl ); - DBG( DBG_LOW, "RD_ScanControl = 0x%02x\n", ps->AsicReg.RD_ScanControl ); + DBG( DBG_LOW, "RD_ModeControl = 0x%02x\n", ps->AsicReg.RD_ModeControl ); + DBG( DBG_LOW, "RD_MotorControl = 0x%02x\n", ps->Asic96Reg.RD_MotorControl ); + DBG( DBG_LOW, "RD_ScanControl = 0x%02x\n", ps->AsicReg.RD_ScanControl ); } /*............................................................................. diff --git a/backend/ricoh.c b/backend/ricoh.c index d1f20c09a..110d19a4c 100644 --- a/backend/ricoh.c +++ b/backend/ricoh.c @@ -514,7 +514,8 @@ sane_init (SANE_Int * version_code, SANE_Auth_Callback authorize) continue; /* ignore empty lines */ /* skip white space: */ - for (lp = line; isspace(*lp); ++lp); + for (lp = line; isspace(*lp); ++lp) + ; strcpy (devnam, lp); } fclose (fp);