else, in some cases by adding extra temporary variables.
IMO, it's much better practice to do
void *a;
int *p = a;
*p = 42;
rather than
void *a;
*(int *)a = 42;
okay miod@... to be revisited for some possible const additions later.
-/* $OpenBSD: compat.c,v 1.83 2013/06/20 19:48:32 espie Exp $ */
+/* $OpenBSD: compat.c,v 1.84 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: compat.c,v 1.14 1996/11/06 17:59:01 christos Exp $ */
/*
CompatMake(void *gnp, /* The node to make */
void *pgnp) /* Parent to abort if necessary */
{
- GNode *gn = (GNode *)gnp;
- GNode *pgn = (GNode *)pgnp;
+ GNode *gn = gnp;
+ GNode *pgn = gnp;
GNode *sib;
bool cmdsOk;
-/* $OpenBSD: dir.c,v 1.65 2015/01/16 15:36:29 deraadt Exp $ */
+/* $OpenBSD: dir.c,v 1.66 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: dir.c,v 1.14 1997/03/29 16:51:26 christos Exp $ */
/*
void *
Dir_CopyDir(void *p)
{
- ((struct PathEntry *)p)->refCount++;
+ struct PathEntry *q = p;
+ q->refCount++;
return p;
}
void
Dir_Destroy(void *pp)
{
- struct PathEntry *p = (struct PathEntry *)pp;
+ struct PathEntry *p = pp;
if (--p->refCount == 0) {
ohash_remove(&knownDirectories,
static void
DirPrintDir(void *p)
{
- printf("%s ", ((struct PathEntry *)p)->name);
+ struct PathEntry *q = p;
+ printf("%s ", q->name);
}
void
-/* $OpenBSD: direxpand.c,v 1.5 2010/07/19 19:30:37 espie Exp $ */
+/* $OpenBSD: direxpand.c,v 1.6 2015/01/23 13:18:40 espie Exp $ */
/*
* Copyright (c) 1999,2007 Marc Espie.
*
static void
DirPrintWord(void *word)
{
- printf("%s ", (char *)word);
+ char *s = word;
+ printf("%s ", s);
}
-/* $OpenBSD: dump.c,v 1.6 2014/05/18 08:08:50 espie Exp $ */
+/* $OpenBSD: dump.c,v 1.7 2015/01/23 13:18:40 espie Exp $ */
/*
* Copyright (c) 2012 Marc Espie.
*
static void
TargPrintName(void *gnp)
{
- GNode *gn = (GNode *)gnp;
+ GNode *gn = gnp;
printf("%s ", gn->name);
}
-/* $OpenBSD: engine.c,v 1.49 2014/10/31 13:29:42 gsoares Exp $ */
+/* $OpenBSD: engine.c,v 1.50 2015/01/23 13:18:40 espie Exp $ */
/*
* Copyright (c) 2012 Marc Espie.
*
static void
MakeTimeStamp(void *parent, void *child)
{
- Make_TimeStamp((GNode *)parent, (GNode *)child);
+ Make_TimeStamp(parent, child);
}
bool
-/* $OpenBSD: for.c,v 1.45 2013/11/22 15:47:35 espie Exp $ */
+/* $OpenBSD: for.c,v 1.46 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: for.c,v 1.4 1996/11/06 17:59:05 christos Exp $ */
/*
static void
ForExec(void *valuep, void *argp)
{
- char *value = (char *)valuep;
- For *arg = (For *)argp;
+ char *value = valuep;
+ For *arg = argp;
BUFFER buf;
/* Parse_FromString pushes stuff back, so we need to go over vars in
-/* $OpenBSD: main.c,v 1.106 2015/01/16 15:36:30 deraadt Exp $ */
+/* $OpenBSD: main.c,v 1.107 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: main.c,v 1.34 1997/03/24 20:56:36 gwr Exp $ */
/*
static bool
ReadMakefile(void *p, void *q)
{
- char *fname = (char *)p; /* makefile to read */
- struct dirs *d = (struct dirs *)q;
+ char *fname = p; /* makefile to read */
+ struct dirs *d = q;
FILE *stream;
char *name;
-/* $OpenBSD: make.c,v 1.68 2014/01/06 12:21:45 espie Exp $ */
+/* $OpenBSD: make.c,v 1.69 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: make.c,v 1.10 1996/11/06 17:59:15 christos Exp $ */
/*
* a cycle in the graph, not an error in an
* inferior */
{
- GNode *gn = (GNode *)gnp;
- bool cycle = *(bool *)cyclep;
+ GNode *gn = gnp;
+ bool *cp = cyclep;
+ bool cycle = *cp;
if (gn->built_status == UPTODATE) {
printf("`%s' is up to date.\n", gn->name);
} else if (gn->unmade != 0) {
static void
MakeAddChild(void *to_addp, void *ap)
{
- GNode *gn = (GNode *)to_addp;
+ GNode *gn = to_addp;
+ struct growableArray *a = ap;
if (!gn->must_make && !(gn->type & OP_USE))
- Array_Push((struct growableArray *)ap, gn);
+ Array_Push(a, gn);
}
static void
MakeHandleUse(void *cgnp, void *pgnp)
{
- GNode *cgn = (GNode *)cgnp;
- GNode *pgn = (GNode *)pgnp;
+ GNode *cgn = cgnp;
+ GNode *pgn = pgnp;
if (cgn->type & OP_USE)
Make_HandleUse(cgn, pgn);
-/* $OpenBSD: parse.c,v 1.110 2013/11/22 15:47:35 espie Exp $ */
+/* $OpenBSD: parse.c,v 1.111 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: parse.c,v 1.29 1997/03/10 21:20:04 christos Exp $ */
/*
static int
ParseFindMain(void *gnp, void *dummy UNUSED)
{
- GNode *gn = (GNode *)gnp;
+ GNode *gn = gnp;
if ((gn->type & OP_NOTARGET) == 0 && gn->special == SPECIAL_NONE) {
mainNode = gn;
return 0;
static void
ParseClearPath(void *p)
{
- Lst path = (Lst)p;
+ Lst path = p;
Lst_Destroy(path, Dir_Destroy);
Lst_Init(path);
static void
ParseAddCmd(void *gnp, void *cmd)
{
- GNode *gn = (GNode *)gnp;
+ GNode *gn = gnp;
if (!(gn->type & OP_HAS_COMMANDS))
Lst_AtEnd(&gn->commands, cmd);
static void
ParseHasCommands(void *gnp)
{
- GNode *gn = (GNode *)gnp;
+ GNode *gn = gnp;
gn->type |= OP_HAS_COMMANDS;
}
-/* $OpenBSD: suff.c,v 1.88 2014/05/12 19:11:19 espie Exp $ */
+/* $OpenBSD: suff.c,v 1.89 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: suff.c,v 1.13 1996/11/06 17:59:25 christos Exp $ */
/*
void *sp, /* suffix for which to create a Src structure */
void *lsp) /* list and parent for the new Src */
{
- Suff *s = (Suff *)sp;
- LstSrc *ls = (LstSrc *)lsp;
+ Suff *s = sp;
+ LstSrc *ls = lsp;
Src *s2; /* new Src structure */
Src *targ; /* Target structure */
static void
SuffPrintName(void *p)
{
- Suff *s = (Suff *)p;
+ Suff *s = p;
printf("%s ", s == emptySuff ? "<empty>" : s->name);
}
static void
SuffPrintSuff(void *sp)
{
- Suff *s = (Suff *)sp;
+ Suff *s = sp;
printf("# %-5s ", s->name);
-/* $OpenBSD: varmodifiers.c,v 1.39 2014/09/21 13:43:25 espie Exp $ */
+/* $OpenBSD: varmodifiers.c,v 1.40 2015/01/23 13:18:40 espie Exp $ */
/* $NetBSD: var.c,v 1.18 1997/03/18 19:24:46 christos Exp $ */
/*
static bool
VarUniq(struct Name *word, bool addSpace, Buffer buf, void *lastp)
{
- struct Name *last = (struct Name *)lastp;
+ struct Name *last = lastp;
/* does not match */
if (last->s == NULL || last->e - last->s != word->e - word->s ||
static bool
VarLoop(struct Name *word, bool addSpace, Buffer buf, void *vp)
{
- struct LoopStuff *v = (struct LoopStuff *)vp;
+ struct LoopStuff *v = vp;
if (addSpace)
Buf_AddSpace(buf);
static char *
finish_loop(const char *s, const struct Name *n UNUSED , void *p)
{
- struct LoopStuff *l = (struct LoopStuff *)p;
+ struct LoopStuff *l = p;
return Var_Subst(s, NULL, l->err);
}
static char *
do_def(const char *s, const struct Name *n UNUSED, void *arg)
{
- VarPattern *v = (VarPattern *)arg;
+ VarPattern *v = arg;
if (s == NULL) {
free_patternarg(v);
return NULL;
static char *
do_undef(const char *s, const struct Name *n UNUSED, void *arg)
{
- VarPattern *v = (VarPattern *)arg;
+ VarPattern *v = arg;
if (s != NULL) {
free_patternarg(v);
return NULL;
static char *
do_assign(const char *s, const struct Name *n, void *arg)
{
- VarPattern *v = (VarPattern *)arg;
+ VarPattern *v = arg;
char *msg;
char *result;
static char *
do_exec(const char *s UNUSED, const struct Name *n UNUSED, void *arg)
{
- VarPattern *v = (VarPattern *)arg;
+ VarPattern *v = arg;
char *msg;
char *result;
{
size_t len;
const char *ptr;
- VarPattern *pat = (VarPattern *)patp;
+ VarPattern *pat = patp;
if (*word->s != '\0') {
if (addSpace)
{
size_t wordLen; /* Length of word */
const char *cp; /* General pointer */
- VarPattern *pattern = (VarPattern *)patternp;
+ VarPattern *pattern = patternp;
wordLen = word->e - word->s;
if ((pattern->flags & (VAR_SUB_ONE|VAR_SUB_MATCHED)) !=
static char *
VarQuote(const char *str, const struct Name *n UNUSED, void *islistp)
{
- int islist = *((int *)islistp);
+ int *p = islistp;
+ int islist = *p;
BUFFER buf;
/* This should cover most shells :-( */
static void
free_looparg(void *arg)
{
- struct LoopStuff *l = (struct LoopStuff *)arg;
+ struct LoopStuff *l = arg;
Var_DeleteLoopVar(l->var);
free(l->expand);
static void
free_patternarg(void *p)
{
- VarPattern *vp = (VarPattern *)p;
+ VarPattern *vp = p;
free(vp->lbuffer);
free(vp->rhs);
do_regex(const char *s, const struct Name *n UNUSED, void *arg)
{
VarREPattern p2;
- VarPattern *p = (VarPattern *)arg;
+ VarPattern *p = arg;
int error;
char *result;