summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2008-12-15 02:23:12 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2008-12-15 02:23:12 +0000
commitc5a1054d528dc95b80c280a04e2555a44ed28264 (patch)
tree388dd74ebe08b7faf0b51b09f4fbddb00116423e
parent8c40cedbf308bc349ccfa8ac9e9a396c6e23a32b (diff)
downloadmandoc-c5a1054d528dc95b80c280a04e2555a44ed28264.tar.gz
Linted.
-rw-r--r--Makefile6
-rw-r--r--hash.c22
-rw-r--r--macro.c37
-rw-r--r--mdoc.c33
-rw-r--r--mdocml.c3
5 files changed, 63 insertions, 38 deletions
diff --git a/Makefile b/Makefile
index 45524cae..30f8df5f 100644
--- a/Makefile
+++ b/Makefile
@@ -29,10 +29,10 @@ clean:
rm -f $(CLEAN)
llib-llibmdoc.ln: macro.ln mdoc.ln hash.ln
- $(LINT) $(LINTFLAGS) -Cllibmdoc mdoc.ln macro.ln hash.ln
+ $(LINT) $(LINTFLAGS) -Clibmdoc mdoc.ln macro.ln hash.ln
-llib-llmdocml.ln: mdocml.ln llib-llibmdoc.ln
- $(LINT) $(LINTFLAGS) -Cllibmdoc mdocml.ln llib-llibmdoc.ln
+llib-lmdocml.ln: mdocml.ln llib-llibmdoc.ln
+ $(LINT) $(LINTFLAGS) -Cmdocml mdocml.ln llib-llibmdoc.ln
macro.ln: macro.c private.h
diff --git a/hash.c b/hash.c
index 1bdca064..b79bca78 100644
--- a/hash.c
+++ b/hash.c
@@ -37,7 +37,7 @@ mdoc_hash_free(void *htab)
void *
mdoc_hash_alloc(void)
{
- int i, major, minor, index;
+ int i, major, minor, ind;
const void **htab;
htab = calloc(27 * 26, sizeof(struct mdoc_macro *));
@@ -69,10 +69,10 @@ mdoc_hash_alloc(void)
assert(major >= 0 && major < 27);
assert(minor >= 0 && minor < 26);
- index = (major * 27) + minor;
+ ind = (major * 27) + minor;
- assert(NULL == htab[index]);
- htab[index] = &mdoc_macros[i];
+ assert(NULL == htab[ind]);
+ htab[ind] = &mdoc_macros[i];
}
return((void *)htab);
@@ -82,10 +82,11 @@ mdoc_hash_alloc(void)
int
mdoc_hash_find(const void *arg, const char *tmp)
{
- int major, minor, index, slot;
+ int major, minor, ind, slot;
const void **htab;
- htab = (const void **)arg;
+ htab = /* LINTED */
+ (const void **)arg;
if (0 == tmp[0] || 0 == tmp[1])
return(MDOC_MAX);
@@ -110,13 +111,14 @@ mdoc_hash_find(const void *arg, const char *tmp)
else
minor = tmp[1] - 97;
- index = (major * 27) + minor;
+ ind = (major * 27) + minor;
- if (NULL == htab[index])
+ if (NULL == htab[ind])
return(MDOC_MAX);
- slot = htab[index] - (void *)mdoc_macros;
- assert(0 == slot % sizeof(struct mdoc_macro));
+ slot = htab[ind] - /* LINTED */
+ (void *)mdoc_macros;
+ assert(0 == (size_t)slot % sizeof(struct mdoc_macro));
slot /= sizeof(struct mdoc_macro);
if (0 != strcmp(mdoc_macronames[slot], tmp))
diff --git a/macro.c b/macro.c
index ba57be6a..27f1c084 100644
--- a/macro.c
+++ b/macro.c
@@ -23,12 +23,15 @@
#include "private.h"
-#define _C(p) ((const char **)p)
+#define _CC(p) ((const char **)p)
+static int append_text(struct mdoc *, int,
+ int, int, char *[]);
+static int append_scoped(struct mdoc *, int,
+ int, int, char *[]);
static int isdelim(const char *);
-static int args_next(struct mdoc *, int, int *, char *, char **);
-static int append_text(struct mdoc *, int, int, int, char *[]);
-static int append_scoped(struct mdoc *, int, int, int, char *[]);
+static int args_next(struct mdoc *, int,
+ int *, char *, char **);
static int
@@ -118,21 +121,25 @@ args_next(struct mdoc *mdoc, int tok,
static int
-append_scoped(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
+append_scoped(struct mdoc *mdoc, int tok,
+ int pos, int sz, char *args[])
{
+ assert(sz >= 0);
args[sz] = NULL;
mdoc_block_alloc(mdoc, pos, tok, 0, NULL);
- mdoc_head_alloc(mdoc, pos, tok, sz, _C(args));
+ mdoc_head_alloc(mdoc, pos, tok, (size_t)sz, _CC(args));
mdoc_body_alloc(mdoc, pos, tok);
return(1);
}
static int
-append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
+append_text(struct mdoc *mdoc, int tok,
+ int pos, int sz, char *args[])
{
+ assert(sz >= 0);
args[sz] = NULL;
switch (tok) {
@@ -149,7 +156,8 @@ append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
case (MDOC_Tn):
if (0 == sz && ! mdoc_warn(mdoc, tok, pos, WARN_ARGS_GE1))
return(0);
- mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args));
+ mdoc_elem_alloc(mdoc, pos, tok, 0,
+ NULL, (size_t)sz, _CC(args));
return(1);
case (MDOC_Ar):
@@ -157,7 +165,8 @@ append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
case (MDOC_Cm):
/* FALLTHROUGH */
case (MDOC_Fl):
- mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args));
+ mdoc_elem_alloc(mdoc, pos, tok, 0,
+ NULL, (size_t)sz, _CC(args));
return(1);
case (MDOC_Ad):
@@ -179,7 +188,8 @@ append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
case (MDOC_Vt):
if (0 == sz)
return(mdoc_err(mdoc, tok, pos, ERR_ARGS_GE1));
- mdoc_elem_alloc(mdoc, pos, tok, 0, NULL, sz, _C(args));
+ mdoc_elem_alloc(mdoc, pos, tok, 0,
+ NULL, (size_t)sz, _CC(args));
return(1);
/* ======= ADD MORE MACRO ARGUMENT-LIMITS ABOVE. ======= */
@@ -195,7 +205,7 @@ append_text(struct mdoc *mdoc, int tok, int pos, int sz, char *args[])
int
macro_text(struct mdoc *mdoc, int tok, int ppos, int *pos, char *buf)
{
- int lastarg, j, c, lasttok, lastpunct;
+ int lastarg, c, lasttok, lastpunct, j;
char *args[MDOC_LINEARG_MAX], *p;
lasttok = ppos;
@@ -254,7 +264,7 @@ int
macro_scoped_implicit(struct mdoc *mdoc,
int tok, int ppos, int *pos, char *buf)
{
- int j, c, lastarg, t;
+ int t, c, lastarg, j;
char *args[MDOC_LINEARG_MAX];
struct mdoc_node *n;
@@ -264,6 +274,7 @@ macro_scoped_implicit(struct mdoc *mdoc,
assert( ! (MDOC_EXPLICIT & mdoc_macros[tok].flags));
+ /* LINTED */
for (n = mdoc->last; n; n = n->parent) {
if (MDOC_BLOCK != n->type)
continue;
@@ -297,7 +308,7 @@ again:
/* Command found. */
if (MDOC_MAX != (c = mdoc_find(mdoc, args[j])))
- if ( ! mdoc_warn(mdoc, tok, *pos, WARN_SYNTAX_MACLIKE))
+ if ( ! mdoc_warn(mdoc, tok, lastarg, WARN_SYNTAX_MACLIKE))
return(0);
/* Word found. */
diff --git a/mdoc.c b/mdoc.c
index 69f17e1a..e975dcdd 100644
--- a/mdoc.c
+++ b/mdoc.c
@@ -301,7 +301,7 @@ mdoc_parseln(struct mdoc *mdoc, char *buf)
i--;
- (void)memcpy(tmp, buf + 1, i);
+ (void)memcpy(tmp, buf + 1, (size_t)i);
tmp[i++] = 0;
if (MDOC_MAX == (c = mdoc_find(mdoc, tmp)))
@@ -398,6 +398,9 @@ mdoc_node_append(struct mdoc *mdoc, int pos, struct mdoc_node *p)
nn = mdoc_macronames[p->data.block.tok];
nt = "block";
break;
+ default:
+ abort();
+ /* NOTREACHED */
}
if (NULL == mdoc->first) {
@@ -429,6 +432,9 @@ mdoc_node_append(struct mdoc *mdoc, int pos, struct mdoc_node *p)
on = mdoc_macronames[mdoc->last->data.block.tok];
ot = "block";
break;
+ default:
+ abort();
+ /* NOTREACHED */
}
switch (p->type) {
@@ -575,16 +581,18 @@ mdoc_word_alloc(struct mdoc *mdoc, int pos, const char *word)
static void
argfree(size_t sz, struct mdoc_arg *p)
{
- size_t i, j;
+ int i, j;
if (0 == sz)
return;
assert(p);
- for (i = 0; i < sz; i++)
+ /* LINTED */
+ for (i = 0; i < (int)sz; i++)
if (p[i].sz > 0) {
assert(p[i].value);
- for (j = 0; j < p[i].sz; j++)
+ /* LINTED */
+ for (j = 0; j < (int)p[i].sz; j++)
free(p[i].value[j]);
}
free(p);
@@ -674,13 +682,13 @@ mdoc_find(const struct mdoc *mdoc, const char *key)
static void
argcpy(struct mdoc_arg *dst, const struct mdoc_arg *src)
{
- size_t i;
+ int i;
dst->arg = src->arg;
if (0 == (dst->sz = src->sz))
return;
dst->value = xcalloc(dst->sz, sizeof(char *));
- for (i = 0; i < dst->sz; i++)
+ for (i = 0; i < (int)dst->sz; i++)
dst->value[i] = xstrdup(src->value[i]);
}
@@ -689,13 +697,13 @@ static struct mdoc_arg *
argdup(size_t argsz, const struct mdoc_arg *args)
{
struct mdoc_arg *pp;
- size_t i;
+ int i;
if (0 == argsz)
return(NULL);
pp = xcalloc((size_t)argsz, sizeof(struct mdoc_arg));
- for (i = 0; i < argsz; i++)
+ for (i = 0; i < (int)argsz; i++)
argcpy(&pp[i], &args[i]);
return(pp);
@@ -705,13 +713,14 @@ argdup(size_t argsz, const struct mdoc_arg *args)
static void
paramfree(size_t sz, char **p)
{
- size_t i;
+ int i;
if (0 == sz)
return;
assert(p);
- for (i = 0; i < sz; i++)
+ /* LINTED */
+ for (i = 0; i < (int)sz; i++)
free(p[i]);
free(p);
}
@@ -721,13 +730,13 @@ static char **
paramdup(size_t sz, const char **p)
{
char **pp;
- size_t i;
+ int i;
if (0 == sz)
return(NULL);
pp = xcalloc(sz, sizeof(char *));
- for (i = 0; i < sz; i++)
+ for (i = 0; i < (int)sz; i++)
pp[i] = xstrdup(p[i]);
return(pp);
diff --git a/mdocml.c b/mdocml.c
index a84a1572..20803330 100644
--- a/mdocml.c
+++ b/mdocml.c
@@ -207,6 +207,9 @@ print_node(const struct mdoc_node *n, int indent)
p = mdoc_macronames[n->data.block.tok];
t = "block";
break;
+ default:
+ abort();
+ /* NOTREACHED */
}
for (i = 0; i < indent; i++)