Porównaj commity

...

9 Commity

Autor SHA1 Wiadomość Data
Alex Belkin 2c4bddaaf1 Merge branch 'ci-update' into 'master'
CI: Bump Ubuntu, Fedora, Debian, and Alpine versions

See merge request sane-project/backends!813
2024-04-23 17:01:18 +00:00
Ralph Little 0f472aa205 Merge branch 'editorconfig_inline_comment' into 'master'
.editorconfig: inline comments are forbidden

See merge request sane-project/backends!832
2024-04-19 19:53:22 +00:00
ThierryFR 728ca40272 Merge branch 'escl-force-idle-status' into 'master'
Escl force idle status

See merge request sane-project/backends!835
2024-04-16 20:45:49 +00:00
ThierryFR 113be50f6b Escl force idle status 2024-04-16 20:45:49 +00:00
Guillaume Girol a6d63a72ec .editorconfig: inline comments are forbidden
source: https://spec.editorconfig.org/#no-inline-comments

this makes neovim unhappy, at least.
2024-02-26 12:00:00 +00:00
Alex Belkin 7ccbb3d1a1 CI: Do not use silent rules
Instead use make(1) env MAKEFLAGS set to `-w -O`.

With silent rules we don't see compile commands and only see a error
messages. This is beautiful when there is no errors but harder to
understand the cause when there are errors.

For example, after adding `-Wno-error=unused-but-set-variable`
I still see the error:

  CXX      genesys/libgenesys_la-device.lo
genesys/genesys.cpp:843:19: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
  843 |     for (unsigned i = 0;; ++i) {
      |                   ^

But why? Hard to tell since we don't see compile command line.

With `-w -O` we see each compilation job grouped in the log.

This will help to debug build issues in CI, where reproduction is
costly/harder for a casual contributor. Compilation command is just
above the error. Find errors in log by searching for `error:` or
`warning:` strings.
2023-11-26 15:36:30 +03:00
Alex Belkin 39bf02524f CI: Add -Wunused-but-set-variable for Fedora clang
clang 17 warnings that need to be fixed:

hp-option.c:3812:10: error: variable 'errcount' set but not used [-Werror,-Wunused-but-set-variable]
 3812 |   int i, errcount = 0;
      |          ^

In file included from hp3900.c:59:
./hp3900_sane.c:1755:12: error: variable 'nline' set but not used [-Werror,-Wunused-but-set-variable]
 1755 |   SANE_Int nline = 0;
      |            ^

lexmark_low.c:2500:7: error: variable 'blackLineCount' set but not used [-Werror,-Wunused-but-set-variable]
 2500 |   int blackLineCount = 0;
      |       ^

In file included from plustek_pp.c:124:
./plustek-pp_io.c:425:8: error: variable 'dwTime' set but not used [-Werror,-Wunused-but-set-variable]
  425 |         ULong dwTime = 1;
      |               ^

genesys/genesys.cpp:843:19: error: variable 'i' set but not used [-Werror,-Wunused-but-set-variable]
  843 |     for (unsigned i = 0;; ++i) {
      |                   ^

After fixing them this commit could be reversed.
2023-11-26 15:36:12 +03:00
Alex Belkin f8c3e23aba kodakaio:: Remove Unicode LRO (U+202D) character from comments
GCC 13 error message:

kodakaio.c: In function 'k_init_parametersta':
kodakaio.c:1830:67: error: unpaired UTF-8 bidirectional control character detected [-Werror=bidi-chars=]
 1830 |          * The default color depth is stored in mode_params.depth:<U+202D>
      |                                                                   ~~~~~~~~^
      |                                                                   |       |
      |                                                                   |       end of bidirectional context
      |                                                                   U+202D (LEFT-TO-RIGHT OVERRIDE)

Fixes: 06fae3526 ("kodakaio params.depth corrected for lineart, color mode made the default.")
2023-11-26 14:54:07 +03:00
Alex Belkin 623b8452a1 CI: Bump Ubuntu, Fedora, Debian, and Alpine versions
Alpine (3.15 -> 3.18)
  Debian (10 -> 12)
  Fedora (36 -> 39)
  Ubuntu (22.04 -> 23.10)

They have newer compilers and new warnings.
2023-11-26 14:54:07 +03:00
7 zmienionych plików z 191 dodań i 29 usunięć

Wyświetl plik

@ -6,7 +6,8 @@
# Your editor may need a plugin for this configuration to take effect.
# See http://editorconfig.org/#download for details.
root = true ; look no further
; look no further
root = true
[*]
charset = utf-8

Wyświetl plik

@ -5,7 +5,7 @@
variables:
REGISTRY_HUB: "registry.gitlab.com/sane-project/ci-envs"
CONFIGURE_MINI: "--enable-silent-rules"
CONFIGURE_MINI: ""
CONFIGURE_FULL: "--with-usb --with-usb-record-replay --with-avahi --enable-pnm-backend --with-libcurl --with-poppler-glib"
stages:
@ -39,14 +39,7 @@ make-dist:
- cd build
- tar xzf ../sane-backends-*.tar.gz --strip-components=1
- (set -x; ./configure $CONFIGURE_OPTS)
- eval "(set -x; make -j2 -k $MAKE_FLAGS)"
debian-10-full:
image: $REGISTRY_HUB:debian-buster-full
variables:
CONFIGURE_OPTS: "$CONFIGURE_MINI $CONFIGURE_FULL"
MAKE_FLAGS: "CFLAGS=-Werror CXXFLAGS=-Werror"
<<: *compile_definition
- eval "(set -x; make -w -O -j2 -k $MAKE_FLAGS)"
debian-11-mini:
image: $REGISTRY_HUB:debian-bullseye-mini
@ -59,8 +52,8 @@ debian-11-mini:
# environment is used to keep some of the HTML documentation that's
# available from our website up-to-date.
debian-11-full:
image: $REGISTRY_HUB:debian-bullseye-full
debian-12-full:
image: $REGISTRY_HUB:debian-bookworm-full
variables:
CONFIGURE_OPTS: "$CONFIGURE_MINI $CONFIGURE_FULL"
MAKE_FLAGS: "CFLAGS=-Werror CXXFLAGS=-Werror"
@ -76,22 +69,22 @@ debian-11-full:
- doc/sanei-html
expire_in: 1 day
fedora-36-clang:
image: $REGISTRY_HUB:fedora-36-clang
fedora-39-clang:
image: $REGISTRY_HUB:fedora-39-clang
variables:
CONFIGURE_OPTS: "$CONFIGURE_MINI $CONFIGURE_FULL"
MAKE_FLAGS: "CFLAGS=-Werror CXXFLAGS=-Werror"
MAKE_FLAGS: "CFLAGS='-Werror -Wno-error=unused-but-set-variable' CXXFLAGS='-Werror -Wno-error=unused-but-set-variable'"
<<: *compile_definition
alpine-3.15-musl:
image: $REGISTRY_HUB:alpine-3.15-musl
alpine-3.18-musl:
image: $REGISTRY_HUB:alpine-3.18-musl
variables:
CONFIGURE_OPTS: "$CONFIGURE_MINI $CONFIGURE_FULL"
MAKE_FLAGS: "CFLAGS='-Werror -Wno-pedantic' CXXFLAGS=-Werror"
<<: *compile_definition
ubuntu-22.04-lts:
image: $REGISTRY_HUB:ubuntu-jammy-dist
ubuntu-23.10:
image: $REGISTRY_HUB:ubuntu-mantic-dist
variables:
CONFIGURE_OPTS: "$CONFIGURE_MINI $CONFIGURE_FULL"
MAKE_FLAGS: "CFLAGS=-Werror CXXFLAGS=-Werror"
@ -112,7 +105,7 @@ make-distcheck:
image: $REGISTRY_HUB:debian-bullseye-full
stage: snapshot
dependencies:
- debian-11-full
- debian-12-full
script:
- tar xzf sane-backends-*.tar.gz --strip-components=1
- rm sane-backends-*.tar.gz

Wyświetl plik

@ -1345,7 +1345,7 @@ sane_cancel(SANE_Handle h)
}
handler->scanner->work = SANE_FALSE;
handler->cancel = SANE_TRUE;
escl_scanner(handler->device, handler->scanner->scanJob, handler->result);
escl_scanner(handler->device, handler->scanner->scanJob, handler->result, SANE_TRUE);
free(handler->result);
handler->result = NULL;
free(handler->scanner->scanJob);
@ -1566,6 +1566,7 @@ sane_start(SANE_Handle h)
handler->decompress_scan_data = SANE_FALSE;
handler->end_read = SANE_FALSE;
if (handler->scanner->work == SANE_FALSE) {
escl_reset_all_jobs(handler->device);
SANE_Status st = escl_status(handler->device,
handler->scanner->source,
NULL,

Wyświetl plik

@ -248,7 +248,11 @@ SANE_Status escl_scan(capabilities_t *scanner,
void escl_scanner(const ESCL_Device *device,
char *scanJob,
char *result);
char *result,
SANE_Bool status);
SANE_Status escl_reset_all_jobs(ESCL_Device *device);
typedef void CURL;

Wyświetl plik

@ -44,7 +44,32 @@ write_callback(void __sane_unused__*str,
* This function is called in the 'sane_cancel' function.
*/
void
escl_scanner(const ESCL_Device *device, char *scanJob, char *result)
escl_delete(const ESCL_Device *device, char *uri)
{
CURL *curl_handle = NULL;
long answer = 0;
if (uri == NULL)
return;
curl_handle = curl_easy_init();
if (curl_handle != NULL) {
escl_curl_url(curl_handle, device, uri);
curl_easy_setopt(curl_handle, CURLOPT_CUSTOMREQUEST, "DELETE");
if (curl_easy_perform(curl_handle) == CURLE_OK) {
curl_easy_getinfo(curl_handle, CURLINFO_RESPONSE_CODE, &answer);
return;
}
curl_easy_cleanup(curl_handle);
}
}
/**
* \fn void escl_scanner(const ESCL_Device *device, char *result)
* \brief Function that resets the scanner after each scan, using curl.
* This function is called in the 'sane_cancel' function.
*/
void
escl_scanner(const ESCL_Device *device, char *scanJob, char *result, SANE_Bool status)
{
CURL *curl_handle = NULL;
const char *scan_jobs = "/eSCL/";
@ -70,10 +95,15 @@ CURL_CALL:
if (i >= 15) return;
}
curl_easy_cleanup(curl_handle);
if (SANE_STATUS_GOOD != escl_status(device,
PLATEN,
NULL,
NULL))
goto CURL_CALL;
char* end = strrchr(scan_cmd, '/');
*end = 0;
escl_delete(device, scan_cmd);
if (status) {
if (SANE_STATUS_GOOD != escl_status(device,
PLATEN,
NULL,
NULL))
goto CURL_CALL;
}
}
}

Wyświetl plik

@ -29,6 +29,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <libxml/parser.h>
@ -270,3 +271,135 @@ clean_data:
}
return (status);
}
static void
print_xml_job_finish(xmlNode *node,
SANE_Status *job)
{
while (node) {
if (node->type == XML_ELEMENT_NODE) {
if (find_nodes_s(node)) {
if (strcmp((const char *)node->name, "JobState") == 0) {
const char *state = (const char *)xmlNodeGetContent(node);
if (!strcmp(state, "Canceled")) {
*job = SANE_STATUS_GOOD;
DBG(10, "jobId Completed SANE_STATUS_GOOD\n");
}
else if (!strcmp(state, "Aborted")) {
*job = SANE_STATUS_GOOD;
DBG(10, "jobId Completed SANE_STATUS_GOOD\n");
}
else if (!strcmp(state, "Completed")) {
*job = SANE_STATUS_GOOD;
DBG(10, "jobId Completed SANE_STATUS_GOOD\n");
}
}
}
}
print_xml_job_finish(node->children, job);
node = node->next;
}
}
static void
print_xml_reset_all_jobs (xmlNode *node,
ESCL_Device *device)
{
DBG(10, "print_xml_reset_all_jobs\n");
SANE_Status status = SANE_STATUS_DEVICE_BUSY;
while (node) {
if (node->type == XML_ELEMENT_NODE) {
if (find_nodes_s(node)) {
if (strcmp((const char *)node->name, "JobUri") == 0) {
DBG(10, "print_xml_reset_all_jobs: %s\n", node->name);
if (device != NULL) {
print_xml_job_finish (node, &status);
if (status == SANE_STATUS_DEVICE_BUSY) {
char *jobUri = (char *)xmlNodeGetContent(node);
char *job = strrchr((const char *)jobUri, '/');
char *scanj = NULL;
if (job != NULL) {
if (strstr(jobUri,"ScanJobs"))
scanj = strdup("ScanJobs");
else
scanj = strdup("ScanJob");
DBG(10, "print_xml_reset_all_jobs: %s/%s\n", scanj, job);
escl_scanner(device, scanj, job, SANE_FALSE);
free(scanj);
}
DBG(10, "print_xml_reset_all_jobs: sleep to finish the job\n");
}
}
}
}
}
print_xml_reset_all_jobs (node->children,
device);
node = node->next;
}
}
/**
* \fn SANE_Status escl_reset_all_jobs (ESCL_Device *device, , char *scanJob)
* \brief Function that forces the end of jobs, using curl.
* This function is called in the 'sane_start' function.
*
* \return status (if everything is OK, status = SANE_STATUS_GOOD, otherwise, SANE_STATUS_NO_MEM/SANE_STATUS_INVAL)
*/
SANE_Status
escl_reset_all_jobs(ESCL_Device *device)
{
CURL *curl_handle = NULL;
xmlDoc *data = NULL;
xmlNode *node = NULL;
struct idle *var = NULL;
const char *scanner_status = "/eSCL/ScannerStatus";
SANE_Status status = SANE_STATUS_DEVICE_BUSY;
DBG(10, "escl_reset_all_jobs\n");
if (device == NULL)
return (SANE_STATUS_NO_MEM);
DBG(10, "1 - escl_reset_all_jobs\n");
var = (struct idle*)calloc(1, sizeof(struct idle));
if (var == NULL)
return (SANE_STATUS_NO_MEM);
DBG(10, "2 - escl_reset_all_jobs\n");
var->memory = malloc(1);
var->size = 0;
curl_handle = curl_easy_init();
escl_curl_url(curl_handle, device, scanner_status);
curl_easy_setopt(curl_handle, CURLOPT_WRITEFUNCTION, memory_callback_s);
curl_easy_setopt(curl_handle, CURLOPT_WRITEDATA, (void *)var);
curl_easy_setopt(curl_handle, CURLOPT_FOLLOWLOCATION, 1L);
curl_easy_setopt(curl_handle, CURLOPT_MAXREDIRS, 3L);
CURLcode res = curl_easy_perform(curl_handle);
if (res != CURLE_OK) {
DBG( 1, "The scanner didn't respond: %s\n", curl_easy_strerror(res));
status = SANE_STATUS_INVAL;
goto clean_data1;
}
DBG(10, "3 - escl_reset_all_jobs\n");
DBG( 10, "eSCL : Status : %s.\n", var->memory);
data = xmlReadMemory(var->memory, var->size, "file.xml", NULL, 0);
if (data == NULL) {
status = SANE_STATUS_NO_MEM;
goto clean_data1;
}
node = xmlDocGetRootElement(data);
if (node == NULL) {
status = SANE_STATUS_NO_MEM;
goto clean1;
}
print_xml_reset_all_jobs (node, device);
status = SANE_STATUS_GOOD;
clean1:
xmlFreeDoc(data);
clean_data1:
xmlCleanupParser();
xmlMemoryDump();
curl_easy_cleanup(curl_handle);
free(var->memory);
free(var);
return status;
}

Wyświetl plik

@ -1827,7 +1827,7 @@ k_init_parametersta(KodakAio_Scanner * s)
SANE_UNFIX(s->val[OPT_BR_X].w), SANE_UNFIX(s->val[OPT_BR_Y].w));
/*
* The default color depth is stored in mode_params.depth:
* The default color depth is stored in mode_params.depth:
*/
if (mode_params[s->val[OPT_MODE].w].depth == 1)
s->params.depth = 1;