Using enum { buf_len, buf_count } also looks strange, leave it for now.
-- v2: sane.ds: Use sizeof() instead of hard-coded values, avoid zero initializing local variables when not necessary. sane.ds: Clarify how SANE mode names map to ICAP_PIXELTYPE values. sane.ds: Change return type of sane_categorize_value() to void.
From: Dmitry Timoshkov dmitry@baikal.ru
It's not used.
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/sane.ds/options.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
diff --git a/dlls/sane.ds/options.c b/dlls/sane.ds/options.c index a4c4507360f..335e0306f38 100644 --- a/dlls/sane.ds/options.c +++ b/dlls/sane.ds/options.c @@ -115,7 +115,7 @@ TW_UINT16 sane_option_probe_resolution(const char *option_name, struct option_de return sane_find_option(option_name, TYPE_INT, opt); }
-static TW_UINT32 sane_categorize_value(const WCHAR* value, const WCHAR* const* filter[], char* categories, int buf_len) +static void sane_categorize_value(const WCHAR* value, const WCHAR* const* filter[], char* categories, int buf_len) { TW_UINT32 i, j; for(i=0; filter[i]; ++i) @@ -127,13 +127,12 @@ static TW_UINT32 sane_categorize_value(const WCHAR* value, const WCHAR* const* f if (!wcscmp(value, filter[i][j])) { wcstombs(categories, value, buf_len); - return i; + return; } } } categories += buf_len; } - return 0; }
TW_UINT16 sane_option_probe_str(const char* option_name, const WCHAR* const* filter[], char* opt_values, int buf_len)
From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/sane.ds/capability.c | 2 ++ 1 file changed, 2 insertions(+)
diff --git a/dlls/sane.ds/capability.c b/dlls/sane.ds/capability.c index bbe518c8513..5cb4fb19f7a 100644 --- a/dlls/sane.ds/capability.c +++ b/dlls/sane.ds/capability.c @@ -320,6 +320,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio L"gray", 0}; static const WCHAR* rgb[] = {L"Color", L"24bit Color[Fast]", L"24bit Color", L"24 bit Color", L"Color - 16 Million Colors", L"color", 0}; + /* TWPT_BW = 0, TWPT_GRAY = 1, TWPT_RGB = 2 */ static const WCHAR* const* filter[] = {bw, gray, rgb, 0};
TRACE("ICAP_PIXELTYPE\n"); @@ -337,6 +338,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio return twCC; }
+ /* Map current mode name to TWPT_BW (0), TWPT_GRAY (1) or TWPT_RGB (2) */ current_pixeltype = find_value_pos(current_mode, color_modes, buf_len, buf_count); if (current_pixeltype == buf_count) {
From: Dmitry Timoshkov dmitry@baikal.ru
Signed-off-by: Dmitry Timoshkov dmitry@baikal.ru --- dlls/sane.ds/capability.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/dlls/sane.ds/capability.c b/dlls/sane.ds/capability.c index 5cb4fb19f7a..5afa4de7d72 100644 --- a/dlls/sane.ds/capability.c +++ b/dlls/sane.ds/capability.c @@ -312,7 +312,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio TW_UINT32 val; TW_UINT16 current_pixeltype = TWPT_BW; enum { buf_len = 64, buf_count = 3 }; - char color_modes[buf_len * buf_count] = {'\0'}, current_mode[buf_len] = {'\0'}, *output = 0; + char color_modes[buf_len * buf_count] = {'\0'}, current_mode[buf_len]; /* most of the values are taken from https://gitlab.gnome.org/GNOME/simple-scan/-/blob/master/src/scanner.vala */ static const WCHAR* bw[] = {L"Lineart", L"LineArt", L"Black & White", L"Binary", L"Thresholded", L"1-bit Black & White", L"Black and White - Line Art", L"Black and White - Halftone", L"Monochrome", L"bw", 0}; @@ -331,7 +331,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio return twCC; }
- twCC = sane_option_get_str("mode", current_mode, buf_len); + twCC = sane_option_get_str("mode", current_mode, sizeof(current_mode)); if (twCC != TWCC_SUCCESS) { ERR("Unable to retrieve current mode from sane, ICAP_PIXELTYPE unsupported\n"); @@ -376,7 +376,7 @@ static TW_UINT16 SANE_ICAPPixelType (pTW_CAPABILITY pCapability, TW_UINT16 actio twCC = msg_set(pCapability, &val); if ((twCC == TWCC_SUCCESS) && (val < buf_count)) { - output = color_modes + val * buf_len; + char *output = color_modes + val * buf_len; TRACE("Setting pixeltype to %lu: %s\n", val, output); twCC = set_option_value("mode", output); if (twCC != TWCC_SUCCESS) @@ -955,7 +955,7 @@ static TW_UINT16 SANE_CAPFeederEnabled (pTW_CAPABILITY pCapability, TW_UINT16 ac TW_UINT32 val; TW_BOOL enabled; enum { buf_len = 64, buf_count = 2 }; - char paper_sources[buf_len * buf_count] = {'\0'}, current_source[buf_len] = {'\0'}, *output = 0; + char paper_sources[buf_len * buf_count] = {'\0'}, current_source[buf_len], *output; /* most of the values are taken from https://gitlab.gnome.org/GNOME/simple-scan/-/blob/master/src/scanner.vala */ static const WCHAR* flatbed[] = {L"Flatbed", L"FlatBed", L"Platen", L"Normal", L"Document Table", 0}; static const WCHAR* autofeeder[] = {L"Auto", L"ADF", L"ADF Front", L"ADF Back", L"adf", @@ -972,7 +972,7 @@ static TW_UINT16 SANE_CAPFeederEnabled (pTW_CAPABILITY pCapability, TW_UINT16 ac return twCC; }
- twCC = sane_option_get_str("source", current_source, buf_len); + twCC = sane_option_get_str("source", current_source, sizeof(current_source)); if (twCC != TWCC_SUCCESS) { ERR("Unable to retrieve current paper source from sane, CAP_FEEDERENABLED unsupported\n");
This merge request was approved by Esme Povirk.