Skip to content
This repository has been archived by the owner on Jul 29, 2020. It is now read-only.

Lots of code cleanup #44

Merged
merged 50 commits into from
Jul 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
894862d
CMakeLists.txt: re-enable -Wunused
MaxKellermann Jul 13, 2020
14769ae
jpc_qmfb: remove unused functions jpc_*_col()
MaxKellermann Jul 13, 2020
09ac902
jpc_enc: remove unused function dump_passes()
MaxKellermann Jul 13, 2020
8f5bb88
jpc_enc: remove unused variables
MaxKellermann Jul 13, 2020
21640fe
jpc_mct: remove unused function jpc_mct_getsynweight()
MaxKellermann Jul 13, 2020
d17ece7
jpc_dec: remove unused variables
MaxKellermann Jul 13, 2020
2368ae7
jpc_t1enc: remove unused variables
MaxKellermann Jul 13, 2020
242cc9c
jas_cm: work around -Wunused-but-set-parameter
MaxKellermann Jun 19, 2020
5df73c7
jas_icc: work around -Wunused-but-set-parameter
MaxKellermann Jun 19, 2020
31bbfab
jp2_cod: work around -Wunused-but-set-parameter
MaxKellermann Jun 19, 2020
4dd9bf2
jpc_cs: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
3d21a29
jpc_dec: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
a17d321
jpc_t1cod: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
f89503e
jpc_t1dec: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
71ea237
jpc_tagtree: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
83b80fb
mif, pgx, ras: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
df01ace
jas_math: disable -Wshift-negative-value on GCC as well
MaxKellermann Jul 13, 2020
02d5b21
jpg_dummy: suppress -Wunused
MaxKellermann Jul 13, 2020
b71f975
jpc_t1enc: fix error handling in jpc_enc_enccblk()
MaxKellermann Jul 13, 2020
bc3c927
jpc_t1enc: handle jpc_bitstream_sopen() errors in jpc_enc_enccblk()
MaxKellermann Jul 13, 2020
e1d3490
jas_image: simplify jas_image_cmpt_create() error handling
MaxKellermann Jul 1, 2020
9493c19
jas_image: use `bool`
MaxKellermann Jul 1, 2020
a8368d2
jas_image: simplify jas_image_cmpt_copy() error handling
MaxKellermann Jul 1, 2020
86402fc
jas_image: convert more integers to `unsigned`
MaxKellermann Jul 1, 2020
ab42359
jpc_qmfb: use unsigned integers
MaxKellermann Jul 13, 2020
9557fe3
jpc_fix: convert macros to inline functions
MaxKellermann Jul 1, 2020
0b82570
jas_seq: remove unused macro jas_matrix_length()
MaxKellermann Jul 13, 2020
bb497c8
jas_seq: convert macros to inline functions
MaxKellermann Jul 13, 2020
15de202
jas_seq: add macro PRIjas_seqent
MaxKellermann Jul 14, 2020
442c818
appl/img{cmp,info}: move `max_mem` declaration into #ifdef
MaxKellermann Jul 13, 2020
2dcc4fb
appl/imginfo: remove unused variable `verbose`
MaxKellermann Jul 13, 2020
4e53891
jas_stream: work around -Wunused-but-set-parameter
MaxKellermann Jul 13, 2020
a8b7059
jpc_t1cod: make internal functions `static`
MaxKellermann Jul 13, 2020
9193e81
jpc_t1cod: use smaller types for the lookup tables
MaxKellermann Jul 13, 2020
c944614
jpc_t1cod: remove bogus "Avoid compiler warning"
MaxKellermann Jul 14, 2020
b86f257
jas_t1cod: convert macros to inline functions
MaxKellermann Jul 14, 2020
6bb7e63
jpc_mqdec: add `const`
MaxKellermann Jul 14, 2020
db8517f
jas_mqenc: remove unimplemented prototype
MaxKellermann Jul 14, 2020
3059569
jas_mqenc: add `const`
MaxKellermann Jul 14, 2020
82bd56c
jpc_mqcod: use smaller types
MaxKellermann Jul 14, 2020
c6bbe39
jpg_{enc,dec}: work around -Wunused-but-set-parameter
MaxKellermann Jul 14, 2020
ac0704a
mif_cod: work around -Wunused-parameter
MaxKellermann Jul 14, 2020
3b8265f
{jp2,jpc}_dec, jiv: suppress -Wunused-but-set-variable for disabled code
MaxKellermann Jul 14, 2020
830889b
jas_t1cod: convert runtime check to assert()
MaxKellermann Jul 14, 2020
bb05bca
jas_t1cod: add "fall through" comment to suppress
MaxKellermann Jul 14, 2020
f41bb05
jpg_dec: suppress GCC's -Wtype-limits
MaxKellermann Jul 14, 2020
001b17e
jpc_enc: adjust loop variables for -Wsign-compare
MaxKellermann Jul 14, 2020
b28d2c9
jas_image: add `const`
MaxKellermann Jul 14, 2020
389951d
jas_image: convert macros to inline functions
MaxKellermann Jul 14, 2020
f12c24d
jp2_cod: convert macros to inline functions
MaxKellermann Jul 14, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ set(CPACK_GENERATOR "TGZ")
include(CPack)

if (JAS_STRICT)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wno-unused")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pedantic")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -W -Wformat -Wmissing-prototypes -Wstrict-prototypes")
endif()
Expand Down
35 changes: 13 additions & 22 deletions src/appl/imgcmp.c
Original file line number Diff line number Diff line change
Expand Up @@ -169,18 +169,15 @@ int main(int argc, char **argv)
int width;
int height;
int depth;
int numcomps;
double d;
double maxdist;
double mindist;
int compno;
jas_stream_t *origstream;
jas_stream_t *reconstream;
const char *diffpath;
int maxonly;
int minonly;
int fmtid;
size_t max_mem;

verbose = 0;
origpath = 0;
Expand All @@ -191,7 +188,7 @@ int main(int argc, char **argv)
maxonly = 0;
minonly = 0;
#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
max_mem = JAS_DEFAULT_MAX_MEM_USAGE;
size_t max_mem = JAS_DEFAULT_MAX_MEM_USAGE;
#endif

if (jas_init()) {
Expand Down Expand Up @@ -229,7 +226,9 @@ int main(int argc, char **argv)
exit(EXIT_SUCCESS);
break;
case OPT_MAXMEM:
#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
max_mem = strtoull(jas_optarg, 0, 10);
#endif
break;
case OPT_HELP:
default:
Expand Down Expand Up @@ -291,7 +290,7 @@ int main(int argc, char **argv)
jas_stream_close(reconstream);

/* Ensure that both images have the same number of components. */
numcomps = jas_image_numcmpts(origimage);
const unsigned numcomps = jas_image_numcmpts(origimage);
if (jas_image_numcmpts(reconimage) != numcomps) {
fprintf(stderr, "number of components differ (%d != %d)\n",
numcomps, jas_image_numcmpts(reconimage));
Expand All @@ -301,7 +300,7 @@ int main(int argc, char **argv)
/* Compute the difference for each component. */
maxdist = 0;
mindist = FLT_MAX;
for (compno = 0; compno < numcomps; ++compno) {
for (unsigned compno = 0; compno < numcomps; ++compno) {
width = jas_image_cmptwidth(origimage, compno);
height = jas_image_cmptheight(origimage, compno);
depth = jas_image_cmptprec(origimage, compno);
Expand Down Expand Up @@ -433,12 +432,10 @@ double pae(jas_matrix_t *x, jas_matrix_t *y)
{
double s;
double d;
int i;
int j;

s = 0.0;
for (i = 0; i < jas_matrix_numrows(x); i++) {
for (j = 0; j < jas_matrix_numcols(x); j++) {
for (jas_matind_t i = 0; i < jas_matrix_numrows(x); i++) {
for (jas_matind_t j = 0; j < jas_matrix_numcols(x); j++) {
d = JAS_ABS(jas_matrix_get(y, i, j) - jas_matrix_get(x, i, j));
if (d > s) {
s = d;
Expand All @@ -455,12 +452,10 @@ double msen(jas_matrix_t *x, jas_matrix_t *y, int n)
{
double s;
double d;
int i;
int j;

s = 0.0;
for (i = 0; i < jas_matrix_numrows(x); i++) {
for (j = 0; j < jas_matrix_numcols(x); j++) {
for (jas_matind_t i = 0; i < jas_matrix_numrows(x); i++) {
for (jas_matind_t j = 0; j < jas_matrix_numcols(x); j++) {
d = jas_matrix_get(y, i, j) - jas_matrix_get(x, i, j);
if (n == 1) {
s += fabs(d);
Expand Down Expand Up @@ -496,18 +491,14 @@ jas_image_t *makediffimage(jas_matrix_t *origdata, jas_matrix_t *recondata)
{
jas_image_t *diffimage;
jas_matrix_t *diffdata[3];
int width;
int height;
int i;
int j;
int k;
jas_image_cmptparm_t compparms[3];
jas_seqent_t a;
jas_seqent_t b;

diffimage = 0;
width = jas_matrix_numcols(origdata);
height = jas_matrix_numrows(origdata);
const jas_matind_t width = jas_matrix_numcols(origdata);
const jas_matind_t height = jas_matrix_numrows(origdata);

for (i = 0; i < 3; ++i) {
compparms[i].tlx = 0;
Expand All @@ -531,8 +522,8 @@ jas_image_t *makediffimage(jas_matrix_t *origdata, jas_matrix_t *recondata)
}
}

for (j = 0; j < height; ++j) {
for (k = 0; k < width; ++k) {
for (jas_matind_t j = 0; j < height; ++j) {
for (jas_matind_t k = 0; k < width; ++k) {
a = jas_matrix_get(origdata, j, k);
b = jas_matrix_get(recondata, j, k);
if (a > b) {
Expand Down
9 changes: 4 additions & 5 deletions src/appl/imginfo.c
Original file line number Diff line number Diff line change
Expand Up @@ -136,10 +136,8 @@ int main(int argc, char **argv)
int height;
int depth;
int numcmpts;
int verbose;
const char *fmtname;
int debug;
size_t max_mem;
size_t max_samples;
bool max_samples_valid;
char optstr[32];
Expand All @@ -154,18 +152,17 @@ int main(int argc, char **argv)
max_samples = 0;
max_samples_valid = false;
infile = 0;
verbose = 0;
debug = 0;
#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
max_mem = JAS_DEFAULT_MAX_MEM_USAGE;
size_t max_mem = JAS_DEFAULT_MAX_MEM_USAGE;
#endif
dec_opt_spec[0] = '\0';

/* Parse the command line options. */
while ((id = jas_getopt(argc, argv, opts)) >= 0) {
switch (id) {
case OPT_VERBOSE:
verbose = 1;
/* not used - can we remove this option? */
break;
case OPT_VERSION:
printf("%s\n", JAS_VERSION);
Expand All @@ -182,7 +179,9 @@ int main(int argc, char **argv)
max_samples_valid = true;
break;
case OPT_MAXMEM:
#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
max_mem = strtoull(jas_optarg, 0, 10);
#endif
break;
case OPT_DECOPT:
if (dec_opt_spec[0] != '\0') {
Expand Down
14 changes: 10 additions & 4 deletions src/appl/jiv.c
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ typedef struct {

int verbose;

#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
size_t max_mem;
#endif

} cmdopts_t;

Expand Down Expand Up @@ -147,7 +149,7 @@ typedef struct {

int monomode;

int cmptno;
unsigned cmptno;

} gs_t;

Expand All @@ -168,7 +170,7 @@ static void nextcmpt(void);
static void prevcmpt(void);
static int loadimage(void);
static void unloadimage(void);
static int jas_image_render2(jas_image_t *image, int cmptno, float vtlx, float vtly,
static int jas_image_render2(jas_image_t *image, unsigned cmptno, float vtlx, float vtly,
float vsx, float vsy, int vw, int vh, GLshort *vdata);
static int jas_image_render(jas_image_t *image, float vtlx, float vtly,
float vsx, float vsy, int vw, int vh, GLshort *vdata);
Expand Down Expand Up @@ -262,7 +264,9 @@ int main(int argc, char **argv)
cmdopts.verbose = 1;
break;
case 'm':
#if defined(JAS_DEFAULT_MAX_MEM_USAGE)
cmdopts.max_mem = strtoull(jas_optarg, 0, 10);
#endif
break;
case 'V':
printf("%s\n", JAS_VERSION);
Expand Down Expand Up @@ -924,7 +928,7 @@ static int jas_image_render(jas_image_t *image, float vtlx, float vtly,
return -1;
}

static int jas_image_render2(jas_image_t *image, int cmptno, float vtlx,
static int jas_image_render2(jas_image_t *image, unsigned cmptno, float vtlx,
float vtly, float vsx, float vsy, int vw, int vh, GLshort *vdata)
{
int i;
Expand All @@ -934,7 +938,7 @@ static int jas_image_render2(jas_image_t *image, int cmptno, float vtlx,
int v;
GLshort *vdatap;

if (cmptno < 0 || cmptno >= image->numcmpts_) {
if (cmptno >= image->numcmpts_) {
fprintf(stderr, "bad parameter\n");
goto error;
}
Expand Down Expand Up @@ -972,6 +976,8 @@ static void render()
if (cmdopts.verbose) {
// fprintf(stderr, "vtlx=%f, vtly=%f, vsx=%f, vsy=%f\n",
// vtlx, vtly, gs.sx, gs.sy);
/* suppress -Wunused-but-set-variable */
(void)vtlx; (void)vtly;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I recommend to split statements Declare one name (only) per declaration

Suggested change
(void)vtlx; (void)vtly;
(void)vtlx;
(void)vtly;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree on this one. It makes it more readable to me. But I don't care much and can merge anyways.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This isn't supposed to be "readable". This is a kludge to work around a compiler warning for code which is commented out for unknown reasons. Usually, I wouldn't write two statements on one line, but in this case I decided to do so because I didn't want to waste any screen space for this cr*p.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not sure whether this is a good reason to break with the style ;)

}

if (gs.monomode) {
Expand Down
4 changes: 2 additions & 2 deletions src/libjasper/base/jas_cm.c
Original file line number Diff line number Diff line change
Expand Up @@ -378,7 +378,7 @@ jas_cmxform_t *jas_cmxform_create(jas_cmprof_t *inprof, jas_cmprof_t *outprof,
int prfintent;

/* Avoid compiler warnings about unused parameters. */
optimize = 0;
(void)optimize;

prfintent = intent;

Expand Down Expand Up @@ -653,7 +653,7 @@ static int jas_cmpxformseq_appendcnvt(jas_cmpxformseq_t *pxformseq,
return 0;
abort();
/* Avoid compiler warnings about unused parameters. */
pxformseq = 0;
(void)pxformseq;
return -1;
}

Expand Down
22 changes: 10 additions & 12 deletions src/libjasper/base/jas_icc.c
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ static int jas_iccxyz_output(jas_iccattrval_t *attrval, jas_stream_t *out)
static int jas_iccxyz_getsize(jas_iccattrval_t *attrval)
{
/* Avoid compiler warnings about unused parameters. */
attrval = 0;
(void)attrval;

return 12;
}
Expand Down Expand Up @@ -977,8 +977,8 @@ static int jas_icccurv_copy(jas_iccattrval_t *attrval,
jas_iccattrval_t *othattrval)
{
/* Avoid compiler warnings about unused parameters. */
attrval = 0;
othattrval = 0;
(void)attrval;
(void)othattrval;

/* Not yet implemented. */
abort();
Expand Down Expand Up @@ -1073,9 +1073,9 @@ static int jas_icctxtdesc_copy(jas_iccattrval_t *attrval,
jas_icctxtdesc_t *txtdesc = &attrval->data.txtdesc;

/* Avoid compiler warnings about unused parameters. */
attrval = 0;
othattrval = 0;
txtdesc = 0;
(void)attrval;
(void)othattrval;
(void)txtdesc;

/* Not yet implemented. */
abort();
Expand Down Expand Up @@ -1271,11 +1271,9 @@ static void jas_icclut8_destroy(jas_iccattrval_t *attrval)
static int jas_icclut8_copy(jas_iccattrval_t *attrval,
jas_iccattrval_t *othattrval)
{
jas_icclut8_t *lut8 = &attrval->data.lut8;
/* Avoid compiler warnings about unused parameters. */
attrval = 0;
othattrval = 0;
lut8 = 0;
(void)attrval;
(void)othattrval;
abort();
return -1;
}
Expand Down Expand Up @@ -1452,8 +1450,8 @@ static int jas_icclut16_copy(jas_iccattrval_t *attrval,
jas_iccattrval_t *othattrval)
{
/* Avoid compiler warnings about unused parameters. */
attrval = 0;
othattrval = 0;
(void)attrval;
(void)othattrval;
/* Not yet implemented. */
abort();
return -1;
Expand Down
Loading