misc: Another round of CONSTification

This commit is contained in:
Solomon Peachy 2023-11-01 21:17:43 -04:00
parent f1c2004666
commit e2dd3e8217
10 changed files with 28 additions and 22 deletions

View file

@ -179,7 +179,7 @@ sloccount:
sloccount *.[ch] lib*/*.[ch] *.pl
cppcheck:
$(CPPCHECK) -q -v --std=c99 --enable=all --suppress=variableScope --suppress=selfAssignment --suppress=unusedStructMember -I. -I/usr/include $(CPPFLAGS) $(SOURCES) $(LIB70X_SOURCES) $(LIBS6145_SOURCES)
$(CPPCHECK) -q -v --std=c99 --enable=all --suppress=variableScope --check-level=exhaustive --suppress=selfAssignment --suppress=unusedStructMember -I. -I/usr/include $(CPPFLAGS) $(SOURCES) $(LIB70X_SOURCES) $(LIBS6145_SOURCES)
# Test-related stuff
test: all

View file

@ -684,7 +684,7 @@ static int hiti_docmd(struct hiti_ctx *ctx, uint16_t cmdid, const uint8_t *buf,
}
static int hiti_docmd_resp(struct hiti_ctx *ctx, uint16_t cmdid,
uint8_t *buf, uint8_t buf_len,
const uint8_t *buf, uint8_t buf_len,
uint8_t *respbuf, uint16_t *resplen)
{
int ret, num = 0;
@ -1737,7 +1737,7 @@ static uint8_t *hiti_get_correction_data(struct hiti_ctx *ctx, uint8_t mode)
}
static int hiti_seht2(struct hiti_ctx *ctx, uint8_t plane,
uint8_t *buf, uint32_t buf_len)
const uint8_t *buf, uint32_t buf_len)
{
uint8_t cmdbuf[sizeof(struct hiti_seht2)];
struct hiti_seht2 *cmd = (struct hiti_seht2 *)cmdbuf;

View file

@ -80,7 +80,7 @@ typedef void (*M1_Gamma8to14FN)(const struct M1CPCData *cpc,
typedef int (*M1_CLocalEnhancerFN)(const struct M1CPCData *cpc,
int sharp, struct BandImage *img);
typedef int (*M1_CalcRGBRateFN)(uint16_t rows, uint16_t cols, uint8_t *data);
typedef uint8_t (*M1_CalcOpRateMatteFN)(uint16_t rows, uint16_t cols, uint8_t *data);
typedef uint8_t (*M1_CalcOpRateMatteFN)(uint16_t rows, uint16_t cols, const uint8_t *data);
typedef uint8_t (*M1_CalcOpRateGlossFN)(uint16_t rows, uint16_t cols);
typedef struct mitsu_cpd30_data *(*CPD30_GetDataFN)(const char *filename);

View file

@ -716,10 +716,13 @@ static int mitsud90_query_fwver(struct mitsud90_ctx *ctx)
ret = read_data(ctx->conn,
(uint8_t*) &resp, sizeof(resp), &num);
if (!ret)
return CUPS_BACKEND_FAILED;
memcpy(ctx->fwver, resp.fw_ver.version, 6);
ctx->fwver[6] = 0;
return ret;
return CUPS_BACKEND_OK;
}
static int mitsuw5k_get_serno(struct mitsud90_ctx *ctx)
@ -744,10 +747,13 @@ static int mitsuw5k_get_serno(struct mitsud90_ctx *ctx)
ret = read_data(ctx->conn,
cmdbuf, sizeof(cmdbuf), &num);
if (!ret)
return CUPS_BACKEND_FAILED;
memcpy(ctx->serno, cmdbuf + 4, sizeof(cmdbuf)-4);
ctx->serno[sizeof(cmdbuf)-4-1] = 0;
return ret;
return CUPS_BACKEND_OK;
}

View file

@ -50,7 +50,7 @@
typedef void (*dump_announceFN)(FILE *fp);
typedef int (*ImageProcessingFN)(unsigned char *, unsigned short *, void *);
typedef int (*ImageAvrCalcFN)(unsigned char *, unsigned short, unsigned short, unsigned char *);
typedef int (*ImageAvrCalcFN)(const unsigned char *, unsigned short, unsigned short, unsigned char *);
#define LIB6145_NAME "libS6145ImageProcess" DLL_SUFFIX // Official library
#define LIB6145_NAME_RE "libS6145ImageReProcess" DLL_SUFFIX // Reimplemented library

View file

@ -486,14 +486,13 @@ int sinfonia_docmd(struct sinfonia_usbdev *usbh,
INFO(" Result: 0x%02x Error: 0x%02x (0x%02x/0x%02x = %s)\n",
resphdr->result, resphdr->error, resphdr->printer_major,
resphdr->printer_minor, usbh->error_codes(resphdr->printer_major, resphdr->printer_minor));
ret = CUPS_BACKEND_FAILED;
goto fail;
}
return CUPS_BACKEND_OK;
fail:
ERROR("Failed to execute %s command\n", sinfonia_cmd_names(cmdhdr->cmd));
return ret;
return CUPS_BACKEND_FAILED;
}
int sinfonia_flashled(struct sinfonia_usbdev *usbh)
@ -616,6 +615,7 @@ int sinfonia_setparam(struct sinfonia_usbdev *usbh, int target, uint32_t param)
&num))) {
// ERROR("Unable to query param id %02x: %s\n",
// target, sinfonia_paramname(usbh, target));
return ret;
}
return CUPS_BACKEND_OK;

View file

@ -24,7 +24,7 @@
*
*/
#define LIBSINFONIA_VER "0.19"
#define LIBSINFONIA_VER "0.19.1"
#define SINFONIA_HDR1_LEN 0x10
#define SINFONIA_HDR2_LEN 0x64

View file

@ -41,7 +41,7 @@
//#define S6145_UNUSED
#define LIB_VERSION "0.5.2"
#define LIB_VERSION "0.5.3"
#include <string.h>
#include <stdint.h>
@ -183,7 +183,7 @@ struct imageCorrParam {
struct lib6145_ctx; /* Forward-declaration */
static void SetTableData(void *src, void *dest, uint16_t words);
static void SetTableData(const void *src, void *dest, uint16_t words);
static int32_t CheckPrintParam(struct imageCorrParam *corrdata);
static uint16_t LinePrintCalcBit(uint16_t val);
@ -191,7 +191,7 @@ static void GetInfo(struct lib6145_ctx *ctx);
static void Global_Init(struct lib6145_ctx *ctx);
static void SetTableColor(struct lib6145_ctx *ctx, uint8_t plane);
static void LinePrintPreProcess(struct lib6145_ctx *ctx);
static void CTankResetParameter(struct lib6145_ctx *ctx, int32_t *params);
static void CTankResetParameter(struct lib6145_ctx *ctx, const int32_t *params);
static void CTankResetTank(struct lib6145_ctx *ctx);
static void PagePrintPreProcess(struct lib6145_ctx *ctx);
static void PagePrintProcess(struct lib6145_ctx *ctx);
@ -408,7 +408,7 @@ struct lib6145_ctx {
/* **************************** */
int ImageAvrCalc(uint8_t *input, uint16_t cols, uint16_t rows, uint8_t *avg)
int ImageAvrCalc(const uint8_t *input, uint16_t cols, uint16_t rows, uint8_t *avg)
{
uint64_t sum;
uint32_t offset;
@ -500,9 +500,9 @@ int ImageProcessing(unsigned char *in, unsigned short *out, void *corrdata)
/* **************************** */
static void SetTableData(void *src, void *dest, uint16_t words)
static void SetTableData(const void *src, void *dest, uint16_t words)
{
uint16_t *in = src;
const uint16_t *in = src;
uint16_t *out = dest;
while (words--) {
out[words] = le16_to_cpu(in[words]);
@ -985,7 +985,7 @@ static void LinePrintPreProcess(struct lib6145_ctx *ctx)
#endif
}
static void CTankResetParameter(struct lib6145_ctx *ctx, int32_t *params)
static void CTankResetParameter(struct lib6145_ctx *ctx, const int32_t *params)
{
ctx->m_iTrdTankSize = le32_to_cpu(params[0]);
ctx->m_iSndTankSize = le32_to_cpu(params[1]);

View file

@ -932,7 +932,7 @@ static void CImageEffect70_CalcTTD(struct CImageEffect70 *data,
/* Work out the number of times the density of a given color in
a given area exceeds a threshold */
static void CImageEffect70_CalcSA(struct BandImage *img,
int invert, int32_t *in,
int invert, const int32_t *in,
int32_t revX, int32_t *out)
{
int cols, rows;
@ -1644,7 +1644,7 @@ static int CP98xx_DoCorrectGammaTbl(struct CP98xx_GammaParams *Gamma,
step = KH->Step;
end = KH->End;
start = KH->Start;
elements = step * ((end - start) + 1);
elements = (uint64_t) step * ((end - start) + 1);
max = elements * 0xff;
for (j = 0 ; j < rows / step ; j++) {
@ -2434,7 +2434,7 @@ static void M1_GetAroundBrightness(const uint16_t *pSrcBrightness,
const struct SIZE *pSrcSize,
const struct POINT *pPtCenter,
uint16_t *pDstBrightness,
struct SIZE *pDstSize)
const struct SIZE *pDstSize)
{
uint16_t center;
@ -2817,7 +2817,7 @@ uint8_t M1_CalcOpRateGloss(uint16_t rows, uint16_t cols)
}
/* Assumes rowstride = cols */
uint8_t M1_CalcOpRateMatte(uint16_t rows, uint16_t cols, uint8_t *data)
uint8_t M1_CalcOpRateMatte(uint16_t rows, uint16_t cols, const uint8_t *data)
{
uint64_t sum = 0;
int i;

View file

@ -158,7 +158,7 @@ void M1_Gamma8to14(const struct M1CPCData *cpc,
const struct BandImage *in, struct BandImage *out);
int M1_CalcRGBRate(uint16_t rows, uint16_t cols, uint8_t *data);
uint8_t M1_CalcOpRateMatte(uint16_t rows, uint16_t cols, uint8_t *data);
uint8_t M1_CalcOpRateMatte(uint16_t rows, uint16_t cols, const uint8_t *data);
uint8_t M1_CalcOpRateGloss(uint16_t rows, uint16_t cols);
struct M1CPCData *M1_GetCPCData(const char *corrtable_path,