getgrouplist.3, insque.3, malloc_info.3, pthread_create.3, tsearch.3, aio.7: Use C99-style declarations for readability

Rather than writing things such as:

    struct sometype *x;
    ...
    x = malloc(sizeof(*x));

let's use C99 style so that the type info is in the same line as
the allocation:

    struct sometype *x = malloc(sizeof(*x));

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2020-09-05 16:34:34 +02:00
parent 3b7e518d44
commit 48d0510307
6 changed files with 8 additions and 15 deletions

View File

@ -153,7 +153,6 @@ int
main(int argc, char *argv[])
{
int j, ngroups;
gid_t *groups;
struct passwd *pw;
struct group *gr;
@ -164,7 +163,7 @@ main(int argc, char *argv[])
ngroups = atoi(argv[2]);
groups = malloc(sizeof(*groups) * ngroups);
gid_t *groups = malloc(sizeof(*groups) * ngroups);
if (groups == NULL) {
perror("malloc");
exit(EXIT_FAILURE);

View File

@ -180,9 +180,7 @@ struct element {
static struct element *
new_element(void)
{
struct element *e;
e = malloc(sizeof(*e));
struct element *e = malloc(sizeof(*e));
if (e == NULL) {
fprintf(stderr, "malloc() failed\en");
exit(EXIT_FAILURE);

View File

@ -212,7 +212,6 @@ int
main(int argc, char *argv[])
{
int j, tn, sleepTime;
pthread_t *thr;
if (argc < 4) {
fprintf(stderr,
@ -226,7 +225,7 @@ main(int argc, char *argv[])
blockSize = atoi(argv[3]);
sleepTime = (argc > 4) ? atoi(argv[4]) : 0;
thr = calloc(numThreads, sizeof(*thr));
pthread_t *thr = calloc(numThreads, sizeof(*thr));
if (thr == NULL)
errExit("calloc");

View File

@ -324,7 +324,6 @@ int
main(int argc, char *argv[])
{
int s, tnum, opt, num_threads;
struct thread_info *tinfo;
pthread_attr_t attr;
int stack_size;
void *res;
@ -361,7 +360,7 @@ main(int argc, char *argv[])
/* Allocate memory for pthread_create() arguments */
tinfo = calloc(num_threads, sizeof(*tinfo));
struct thread_info *tinfo = calloc(num_threads, sizeof(*tinfo));
if (tinfo == NULL)
handle_error("calloc");

View File

@ -322,12 +322,12 @@ action(const void *nodep, VISIT which, int depth)
int
main(void)
{
int i, *ptr;
int i;
void *val;
srand(time(NULL));
for (i = 0; i < 12; i++) {
ptr = xmalloc(sizeof(*ptr));
int *ptr = xmalloc(sizeof(*ptr));
*ptr = rand() & 0xff;
val = tsearch((void *) ptr, &root, compare);
if (val == NULL)

View File

@ -294,8 +294,6 @@ aioSigHandler(int sig, siginfo_t *si, void *ucontext)
int
main(int argc, char *argv[])
{
struct ioRequest *ioList;
struct aiocb *aiocbList;
struct sigaction sa;
int s, j;
int numReqs; /* Total number of queued I/O requests */
@ -311,11 +309,11 @@ main(int argc, char *argv[])
/* Allocate our arrays */
ioList = calloc(numReqs, sizeof(*ioList));
struct ioRequest *ioList = calloc(numReqs, sizeof(*ioList));
if (ioList == NULL)
errExit("calloc");
aiocbList = calloc(numReqs, sizeof(*aiocbList));
struct aiocb *aiocbList = calloc(numReqs, sizeof(*aiocbList));
if (aiocbList == NULL)
errExit("calloc");