summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristos Zoulas <christos@zoulas.com>2022-09-13 18:46:07 +0000
committerChristos Zoulas <christos@zoulas.com>2022-09-13 18:46:07 +0000
commitf031d557615fd35bb92944fc98ebdf4335fa2f33 (patch)
tree41fb84da3976ea864be0b4f35fb66017b367af7d
parent96a7d4f7d05cbd895b374c496caba3752993b0a0 (diff)
downloadfile-git-f031d557615fd35bb92944fc98ebdf4335fa2f33.tar.gz
- lint fixes
- add missing cvsids - compile with c++ again
-rw-r--r--src/apprentice.c7
-rw-r--r--src/encoding.c8
-rw-r--r--src/file.c7
-rw-r--r--src/fmtcheck.c3
-rw-r--r--src/funcs.c3
-rw-r--r--src/is_json.c5
-rw-r--r--src/is_tar.c5
-rw-r--r--src/memtest.c4
-rw-r--r--src/softmagic.c11
-rw-r--r--src/strlcat.c3
-rw-r--r--src/strlcpy.c3
11 files changed, 41 insertions, 18 deletions
diff --git a/src/apprentice.c b/src/apprentice.c
index 3c60f5a6..56dd053c 100644
--- a/src/apprentice.c
+++ b/src/apprentice.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: apprentice.c,v 1.325 2022/09/10 13:19:26 christos Exp $")
+FILE_RCSID("@(#)$File: apprentice.c,v 1.326 2022/09/13 18:46:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -1068,6 +1068,7 @@ apprentice_magic_strength_1(const struct magic *m)
}
+/*ARGSUSED*/
private size_t
apprentice_magic_strength(const struct magic *m,
size_t nmagic __attribute__((__unused__)))
@@ -1296,7 +1297,8 @@ addentry(struct magic_set *ms, struct magic_entry *me,
(void)memset(&mp[mset[i].count], 0, sizeof(*mp) *
ALLOC_INCR);
mset[i].me = mp;
- mset[i].max = incr;
+ mset[i].max = CAST(uint32_t, incr);
+ assert(mset[i].max == incr);
}
mset[i].me[mset[i].count++] = *me;
memset(me, 0, sizeof(*me));
@@ -2426,6 +2428,7 @@ parse(struct magic_set *ms, struct magic_entry *me, const char *line,
* parse a STRENGTH annotation line from magic file, put into magic[index - 1]
* if valid
*/
+/*ARGSUSED*/
private int
parse_strength(struct magic_set *ms, struct magic_entry *me, const char *line,
size_t len __attribute__((__unused__)))
diff --git a/src/encoding.c b/src/encoding.c
index e40cb62c..4481a897 100644
--- a/src/encoding.c
+++ b/src/encoding.c
@@ -35,7 +35,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: encoding.c,v 1.38 2022/06/10 13:40:17 christos Exp $")
+FILE_RCSID("@(#)$File: encoding.c,v 1.39 2022/09/13 18:46:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -486,9 +486,11 @@ looks_ucs16(const unsigned char *bf, size_t nbytes, file_unichar_t *ubf,
uint32_t uc;
if (bigend)
- uc = bf[i + 1] | (CAST(file_unichar_t, bf[i]) << 8);
+ uc = CAST(uint32_t,
+ bf[i + 1] | (CAST(file_unichar_t, bf[i]) << 8));
else
- uc = bf[i] | (CAST(file_unichar_t, bf[i + 1]) << 8);
+ uc = CAST(uint32_t,
+ bf[i] | (CAST(file_unichar_t, bf[i + 1]) << 8));
uc &= 0xffff;
diff --git a/src/file.c b/src/file.c
index e01380aa..1566a17f 100644
--- a/src/file.c
+++ b/src/file.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: file.c,v 1.203 2022/08/17 08:47:47 christos Exp $")
+FILE_RCSID("@(#)$File: file.c,v 1.204 2022/09/13 18:46:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -513,7 +513,7 @@ unwrap(struct magic_set *ms, const char *fn)
int wid = 0, cwid;
int e = 0;
size_t fi = 0, fimax = 100;
- char **flist = malloc(sizeof(*flist) * fimax);
+ char **flist = CAST(char **, malloc(sizeof(*flist) * fimax));
if (flist == NULL)
out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list");
@@ -532,7 +532,8 @@ out: file_err(EXIT_FAILURE, "Cannot allocate memory for file list");
line[len - 1] = '\0';
if (fi >= fimax) {
fimax += 100;
- char **nf = realloc(flist, fimax * sizeof(*flist));
+ char **nf = CAST(char **,
+ realloc(flist, fimax * sizeof(*flist)));
if (nf == NULL)
goto out;
flist = nf;
diff --git a/src/fmtcheck.c b/src/fmtcheck.c
index fcad436b..94c47ebf 100644
--- a/src/fmtcheck.c
+++ b/src/fmtcheck.c
@@ -29,6 +29,9 @@
*/
#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: fmtcheck.c,v 1.4 2022/09/13 18:46:07 christos Exp $")
+#endif /* lint */
#include <stdio.h>
#include <string.h>
diff --git a/src/funcs.c b/src/funcs.c
index 7186435c..41c4106c 100644
--- a/src/funcs.c
+++ b/src/funcs.c
@@ -27,7 +27,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: funcs.c,v 1.130 2022/07/04 19:44:35 christos Exp $")
+FILE_RCSID("@(#)$File: funcs.c,v 1.131 2022/09/13 18:46:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -686,6 +686,7 @@ file_regcomp(struct magic_set *ms file_locale_used, file_regex_t *rx,
return rc;
}
+/*ARGSUSED*/
protected int
file_regexec(struct magic_set *ms file_locale_used, file_regex_t *rx,
const char *str, size_t nmatch, regmatch_t* pmatch, int eflags)
diff --git a/src/is_json.c b/src/is_json.c
index ecc3fc03..43369c31 100644
--- a/src/is_json.c
+++ b/src/is_json.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_json.c,v 1.25 2022/07/06 19:05:56 christos Exp $")
+FILE_RCSID("@(#)$File: is_json.c,v 1.26 2022/09/13 18:46:07 christos Exp $")
#endif
#include "magic.h"
@@ -122,6 +122,7 @@ json_skip_space(const unsigned char *uc, const unsigned char *ue)
return uc;
}
+/*ARGSUSED*/
static int
json_parse_string(const unsigned char **ucp, const unsigned char *ue,
size_t lvl __file_debugused)
@@ -268,6 +269,7 @@ out:
return 0;
}
+/*ARGSUSED*/
static int
json_parse_number(const unsigned char **ucp, const unsigned char *ue,
size_t lvl __file_debugused)
@@ -319,6 +321,7 @@ out:
return got;
}
+/*ARGSUSED*/
static int
json_parse_const(const unsigned char **ucp, const unsigned char *ue,
const char *str, size_t len, size_t lvl __file_debugused)
diff --git a/src/is_tar.c b/src/is_tar.c
index cb839083..54cd4945 100644
--- a/src/is_tar.c
+++ b/src/is_tar.c
@@ -40,7 +40,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: is_tar.c,v 1.46 2022/09/07 15:37:58 christos Exp $")
+FILE_RCSID("@(#)$File: is_tar.c,v 1.47 2022/09/13 18:46:07 christos Exp $")
#endif
#include "magic.h"
@@ -113,7 +113,8 @@ is_tar(const unsigned char *buf, size_t nbytes)
/* If the file looks like Gentoo GLEP 78 binary package (GPKG),
* don't waste time on further checks and fall back to magic rules.
*/
- nulp = memchr(header->header.name, 0, sizeof(header->header.name));
+ nulp = CAST(const char *,
+ memchr(header->header.name, 0, sizeof(header->header.name)));
if (nulp != NULL && nulp >= header->header.name + sizeof(gpkg_match) &&
memcmp(nulp - sizeof(gpkg_match) + 1, gpkg_match,
sizeof(gpkg_match)) == 0)
diff --git a/src/memtest.c b/src/memtest.c
index f9506f6e..8423c4a1 100644
--- a/src/memtest.c
+++ b/src/memtest.c
@@ -25,6 +25,10 @@
* SUCH DAMAGE.
*/
+#ifndef lint
+FILE_RCSID("@(#)$File: memtest.c,v 1.3 2022/09/13 18:46:07 christos Exp $")
+#endif
+
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
diff --git a/src/softmagic.c b/src/softmagic.c
index 3c329e7a..d95f7f27 100644
--- a/src/softmagic.c
+++ b/src/softmagic.c
@@ -32,7 +32,7 @@
#include "file.h"
#ifndef lint
-FILE_RCSID("@(#)$File: softmagic.c,v 1.327 2022/09/10 13:19:26 christos Exp $")
+FILE_RCSID("@(#)$File: softmagic.c,v 1.328 2022/09/13 18:46:07 christos Exp $")
#endif /* lint */
#include "magic.h"
@@ -43,7 +43,7 @@ FILE_RCSID("@(#)$File: softmagic.c,v 1.327 2022/09/10 13:19:26 christos Exp $")
#include <time.h>
#include "der.h"
-private int match(struct magic_set *, struct magic *, file_regex_t **, uint32_t,
+private int match(struct magic_set *, struct magic *, file_regex_t **, size_t,
const struct buffer *, size_t, int, int, int, uint16_t *,
uint16_t *, int *, int *, int *, int *);
private int mget(struct magic_set *, struct magic *, const struct buffer *,
@@ -203,7 +203,7 @@ file_fmtcheck(struct magic_set *ms, const char *desc, const char *def,
*/
private int
match(struct magic_set *ms, struct magic *magic, file_regex_t **magic_rxcomp,
- uint32_t nmagic, const struct buffer *b, size_t offset, int mode, int text,
+ size_t nmagic, const struct buffer *b, size_t offset, int mode, int text,
int flip, uint16_t *indir_count, uint16_t *name_count,
int *printed_something, int *need_separator, int *returnval,
int *found_match)
@@ -1862,8 +1862,8 @@ mget(struct magic_set *ms, struct magic *m, const struct buffer *b,
{
if ((rv = match(ms, mlp->magic, mlp->magic_rxcomp,
mlp->nmagic, &bb, 0, BINTEST, text, 0, indir_count,
- name_count, printed_something, need_separator, NULL,
- NULL)) != 0)
+ name_count, printed_something, need_separator,
+ NULL, NULL)) != 0)
break;
}
@@ -2297,7 +2297,6 @@ magiccheck(struct magic_set *ms, struct magic *m, file_regex_t **m_cache)
default:
return -1;
- break;
}
break;
}
diff --git a/src/strlcat.c b/src/strlcat.c
index 9692bc10..4dd569bf 100644
--- a/src/strlcat.c
+++ b/src/strlcat.c
@@ -18,6 +18,9 @@
/* OPENBSD ORIGINAL: lib/libc/string/strlcat.c */
#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: strlcat.c,v 1.3 2022/09/13 18:46:07 christos Exp $")
+#endif
#include <sys/types.h>
#include <string.h>
diff --git a/src/strlcpy.c b/src/strlcpy.c
index 992501c8..5ea390b9 100644
--- a/src/strlcpy.c
+++ b/src/strlcpy.c
@@ -18,6 +18,9 @@
/* OPENBSD ORIGINAL: lib/libc/string/strlcpy.c */
#include "file.h"
+#ifndef lint
+FILE_RCSID("@(#)$File: strlcpy.c,v 1.3 2022/09/13 18:46:07 christos Exp $")
+#endif
#include <sys/types.h>
#include <string.h>