mirror of git://git.gnupg.org/gnupg.git
tests/gpgscm: Fix use of pointer.
* tests/gpgscm/scheme-private.h (struct scheme): Use (void *) for alloc_seg. * tests/gpgscm/scheme.c (alloc_cellseg): Use (void *) for cp. Use (void *) for coercion of address calculation. -- In old C language, (char *) means an address. In modern C, it's specifically an address with alignment=1. It's good to use (void *) for an address, because newer compiler emits warnings. Note: in this particular case, it is just a warning and the code is safe against invalid alignment, though. Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This commit is contained in:
parent
9799b5d18f
commit
68eb5fbd37
|
@ -78,7 +78,7 @@ int tracing;
|
||||||
#ifndef CELL_NSEGMENT
|
#ifndef CELL_NSEGMENT
|
||||||
#define CELL_NSEGMENT 10 /* # of segments for cells */
|
#define CELL_NSEGMENT 10 /* # of segments for cells */
|
||||||
#endif
|
#endif
|
||||||
char *alloc_seg[CELL_NSEGMENT];
|
void *alloc_seg[CELL_NSEGMENT];
|
||||||
pointer cell_seg[CELL_NSEGMENT];
|
pointer cell_seg[CELL_NSEGMENT];
|
||||||
int last_cell_seg;
|
int last_cell_seg;
|
||||||
|
|
||||||
|
|
|
@ -602,7 +602,7 @@ static int alloc_cellseg(scheme *sc, int n) {
|
||||||
pointer newp;
|
pointer newp;
|
||||||
pointer last;
|
pointer last;
|
||||||
pointer p;
|
pointer p;
|
||||||
char *cp;
|
void *cp;
|
||||||
long i;
|
long i;
|
||||||
int k;
|
int k;
|
||||||
int adj=ADJ;
|
int adj=ADJ;
|
||||||
|
@ -614,14 +614,14 @@ static int alloc_cellseg(scheme *sc, int n) {
|
||||||
for (k = 0; k < n; k++) {
|
for (k = 0; k < n; k++) {
|
||||||
if (sc->last_cell_seg >= CELL_NSEGMENT - 1)
|
if (sc->last_cell_seg >= CELL_NSEGMENT - 1)
|
||||||
return k;
|
return k;
|
||||||
cp = (char*) sc->malloc(CELL_SEGSIZE * sizeof(struct cell)+adj);
|
cp = sc->malloc(CELL_SEGSIZE * sizeof(struct cell)+adj);
|
||||||
if (cp == 0)
|
if (cp == 0)
|
||||||
return k;
|
return k;
|
||||||
i = ++sc->last_cell_seg ;
|
i = ++sc->last_cell_seg ;
|
||||||
sc->alloc_seg[i] = cp;
|
sc->alloc_seg[i] = cp;
|
||||||
/* adjust in TYPE_BITS-bit boundary */
|
/* adjust in TYPE_BITS-bit boundary */
|
||||||
if(((unsigned long)cp)%adj!=0) {
|
if(((unsigned long)cp)%adj!=0) {
|
||||||
cp=(char*)(adj*((unsigned long)cp/adj+1));
|
cp=(void *)(adj*((unsigned long)cp/adj+1));
|
||||||
}
|
}
|
||||||
/* insert new segment in address order */
|
/* insert new segment in address order */
|
||||||
newp=(pointer)cp;
|
newp=(pointer)cp;
|
||||||
|
|
Loading…
Reference in New Issue