From 4a7db9da8eb64fa6cb376c0d6635c9d071dbb5f1 Mon Sep 17 00:00:00 2001 From: rillig Date: Fri, 2 Apr 2021 12:16:50 +0000 Subject: [PATCH] lint: add parentheses after sizeof, as required by share/misc/style No functional change. --- tests/usr.bin/xlint/lint1/d_c99_init.c | 4 +- tests/usr.bin/xlint/lint1/msg_144.c | 4 +- usr.bin/xlint/common/tyname.c | 10 ++--- usr.bin/xlint/lint1/cgram.y | 8 ++-- usr.bin/xlint/lint1/decl.c | 32 +++++++-------- usr.bin/xlint/lint1/err.c | 6 +-- usr.bin/xlint/lint1/func.c | 14 +++---- usr.bin/xlint/lint1/init.c | 10 ++--- usr.bin/xlint/lint1/lex.c | 52 ++++++++++++------------ usr.bin/xlint/lint1/main1.c | 6 +-- usr.bin/xlint/lint1/mem1.c | 18 ++++----- usr.bin/xlint/lint1/tree.c | 36 ++++++++--------- usr.bin/xlint/lint2/chk.c | 6 +-- usr.bin/xlint/lint2/emit2.c | 6 +-- usr.bin/xlint/lint2/hash.c | 12 +++--- usr.bin/xlint/lint2/main2.c | 8 ++-- usr.bin/xlint/lint2/read.c | 56 +++++++++++++------------- usr.bin/xlint/xlint/xlint.c | 48 +++++++++++----------- 18 files changed, 168 insertions(+), 168 deletions(-) diff --git a/tests/usr.bin/xlint/lint1/d_c99_init.c b/tests/usr.bin/xlint/lint1/d_c99_init.c index c93e1ce60674..1b0a7af2f56f 100644 --- a/tests/usr.bin/xlint/lint1/d_c99_init.c +++ b/tests/usr.bin/xlint/lint1/d_c99_init.c @@ -1,4 +1,4 @@ -/* $NetBSD: d_c99_init.c,v 1.30 2021/04/01 14:20:30 rillig Exp $ */ +/* $NetBSD: d_c99_init.c,v 1.31 2021/04/02 12:16:50 rillig Exp $ */ # 3 "d_c99_init.c" /* @@ -185,7 +185,7 @@ struct point points[] = { * extend_if_array_of_unknown_size, setcomplete is called too * early. */ - sizeof points, + sizeof(points), 4 } }; diff --git a/tests/usr.bin/xlint/lint1/msg_144.c b/tests/usr.bin/xlint/lint1/msg_144.c index 05acbb10dc50..b938794027c9 100644 --- a/tests/usr.bin/xlint/lint1/msg_144.c +++ b/tests/usr.bin/xlint/lint1/msg_144.c @@ -1,4 +1,4 @@ -/* $NetBSD: msg_144.c,v 1.3 2021/01/31 11:12:07 rillig Exp $ */ +/* $NetBSD: msg_144.c,v 1.4 2021/04/02 12:16:50 rillig Exp $ */ # 3 "msg_144.c" // Test for message: cannot take size/alignment of function [144] @@ -6,5 +6,5 @@ unsigned long example(void) { - return sizeof example; /* expect: 144 */ + return sizeof(example); /* expect: 144 */ } diff --git a/usr.bin/xlint/common/tyname.c b/usr.bin/xlint/common/tyname.c index 32884e34d216..fe330fb6be6e 100644 --- a/usr.bin/xlint/common/tyname.c +++ b/usr.bin/xlint/common/tyname.c @@ -1,4 +1,4 @@ -/* $NetBSD: tyname.c,v 1.36 2021/03/27 12:42:22 rillig Exp $ */ +/* $NetBSD: tyname.c,v 1.37 2021/04/02 12:16:50 rillig Exp $ */ /*- * Copyright (c) 2005 The NetBSD Foundation, Inc. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tyname.c,v 1.36 2021/03/27 12:42:22 rillig Exp $"); +__RCSID("$NetBSD: tyname.c,v 1.37 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -74,7 +74,7 @@ new_name_tree_node(const char *name) { name_tree_node *n; - n = xmalloc(sizeof *n); + n = xmalloc(sizeof(*n)); n->ntn_name = xstrdup(name); n->ntn_less = NULL; n->ntn_greater = NULL; @@ -137,9 +137,9 @@ buf_add(buffer *buf, const char *s) static void buf_add_int(buffer *buf, int n) { - char num[1 + sizeof n * CHAR_BIT + 1]; + char num[1 + sizeof(n) * CHAR_BIT + 1]; - snprintf(num, sizeof num, "%d", n); + snprintf(num, sizeof(num), "%d", n); buf_add(buf, num); } diff --git a/usr.bin/xlint/lint1/cgram.y b/usr.bin/xlint/lint1/cgram.y index ac1144a2875b..154b1832417a 100644 --- a/usr.bin/xlint/lint1/cgram.y +++ b/usr.bin/xlint/lint1/cgram.y @@ -1,5 +1,5 @@ %{ -/* $NetBSD: cgram.y,v 1.210 2021/04/02 11:53:25 rillig Exp $ */ +/* $NetBSD: cgram.y,v 1.211 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -35,7 +35,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: cgram.y,v 1.210 2021/04/02 11:53:25 rillig Exp $"); +__RCSID("$NetBSD: cgram.y,v 1.211 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -1197,7 +1197,7 @@ pointer: asterisk: T_ASTERISK { - $$ = xcalloc(1, sizeof *$$); + $$ = xcalloc(1, sizeof(*$$)); $$->p_pcnt = 1; } ; @@ -1213,7 +1213,7 @@ type_qualifier_list: type_qualifier: T_QUAL { - $$ = xcalloc(1, sizeof *$$); + $$ = xcalloc(1, sizeof(*$$)); if ($1 == CONST) { $$->p_const = true; } else if ($1 == VOLATILE) { diff --git a/usr.bin/xlint/lint1/decl.c b/usr.bin/xlint/lint1/decl.c index 555dd38b29d1..099992f0a357 100644 --- a/usr.bin/xlint/lint1/decl.c +++ b/usr.bin/xlint/lint1/decl.c @@ -1,4 +1,4 @@ -/* $NetBSD: decl.c,v 1.169 2021/04/02 11:53:25 rillig Exp $ */ +/* $NetBSD: decl.c,v 1.170 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: decl.c,v 1.169 2021/04/02 11:53:25 rillig Exp $"); +__RCSID("$NetBSD: decl.c,v 1.170 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -91,7 +91,7 @@ initdecl(void) int i; /* declaration stack */ - dcs = xcalloc(1, sizeof *dcs); + dcs = xcalloc(1, sizeof(*dcs)); dcs->d_ctx = EXTERN; dcs->d_ldlsym = &dcs->d_dlsyms; @@ -99,7 +99,7 @@ initdecl(void) inittyp(); /* shared type structures */ - typetab = xcalloc(NTSPEC, sizeof *typetab); + typetab = xcalloc(NTSPEC, sizeof(*typetab)); for (i = 0; i < NTSPEC; i++) typetab[i].t_tspec = NOTSPEC; typetab[BOOL].t_tspec = BOOL; @@ -163,7 +163,7 @@ expr_dup_type(const type_t *tp) { type_t *ntp; - ntp = expr_zalloc(sizeof *ntp); + ntp = expr_zalloc(sizeof(*ntp)); *ntp = *tp; return ntp; } @@ -594,7 +594,7 @@ begin_declaration_level(scl_t sc) dinfo_t *di; /* put a new element on the declaration stack */ - di = xcalloc(1, sizeof *di); + di = xcalloc(1, sizeof(*di)); di->d_next = dcs; dcs = di; di->d_ctx = sc; @@ -1261,7 +1261,7 @@ bitfield(sym_t *dsym, int len) { if (dsym == NULL) { - dsym = getblk(sizeof *dsym); + dsym = getblk(sizeof(*dsym)); dsym->s_name = unnamed; dsym->s_kind = FMEMBER; dsym->s_scl = MOS; @@ -1333,7 +1333,7 @@ add_pointer(sym_t *decl, pqinf_t *pi) return decl; while (pi != NULL) { - *tpp = tp = getblk(sizeof *tp); + *tpp = tp = getblk(sizeof(*tp)); tp->t_tspec = PTR; tp->t_const = pi->p_const; tp->t_volatile = pi->p_volatile; @@ -1360,7 +1360,7 @@ add_array(sym_t *decl, bool dim, int n) if (*tpp == NULL) return decl; - *tpp = tp = getblk(sizeof *tp); + *tpp = tp = getblk(sizeof(*tp)); tp->t_tspec = ARRAY; tp->t_subt = dcs->d_type; tp->t_dim = n; @@ -1415,7 +1415,7 @@ add_function(sym_t *decl, sym_t *args) if (*tpp == NULL) return decl; - *tpp = tp = getblk(sizeof *tp); + *tpp = tp = getblk(sizeof(*tp)); tp->t_tspec = FUNC; tp->t_subt = dcs->d_next->d_type; if ((tp->t_proto = dcs->d_proto) != false) @@ -1669,19 +1669,19 @@ mktag(sym_t *tag, tspec_t kind, bool decl, bool semi) } if (tag->s_scl == NOSCL) { tag->s_scl = scl; - tag->s_type = tp = getblk(sizeof *tp); + tag->s_type = tp = getblk(sizeof(*tp)); tp->t_packed = dcs->d_packed; } else { tp = tag->s_type; } } else { - tag = getblk(sizeof *tag); + tag = getblk(sizeof(*tag)); tag->s_name = unnamed; UNIQUE_CURR_POS(tag->s_def_pos); tag->s_kind = FTAG; tag->s_scl = scl; tag->s_block_level = -1; - tag->s_type = tp = getblk(sizeof *tp); + tag->s_type = tp = getblk(sizeof(*tp)); tp->t_packed = dcs->d_packed; dcs->d_next->d_nonempty_decl = true; } @@ -1689,12 +1689,12 @@ mktag(sym_t *tag, tspec_t kind, bool decl, bool semi) if (tp->t_tspec == NOTSPEC) { tp->t_tspec = kind; if (kind != ENUM) { - tp->t_str = getblk(sizeof *tp->t_str); + tp->t_str = getblk(sizeof(*tp->t_str)); tp->t_str->sou_align_in_bits = CHAR_SIZE; tp->t_str->sou_tag = tag; } else { tp->t_is_enum = true; - tp->t_enum = getblk(sizeof *tp->t_enum); + tp->t_enum = getblk(sizeof(*tp->t_enum)); tp->t_enum->en_tag = tag; } setcomplete(tp, false); @@ -2862,7 +2862,7 @@ abstract_name(void) lint_assert(dcs->d_ctx == ABSTRACT || dcs->d_ctx == PROTO_ARG); - sym = getblk(sizeof *sym); + sym = getblk(sizeof(*sym)); sym->s_name = unnamed; sym->s_def = DEF; diff --git a/usr.bin/xlint/lint1/err.c b/usr.bin/xlint/lint1/err.c index cde47bd52290..81ba5ecb3d66 100644 --- a/usr.bin/xlint/lint1/err.c +++ b/usr.bin/xlint/lint1/err.c @@ -1,4 +1,4 @@ -/* $NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $ */ +/* $NetBSD: err.c,v 1.100 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: err.c,v 1.99 2021/03/30 15:18:19 rillig Exp $"); +__RCSID("$NetBSD: err.c,v 1.100 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -405,7 +405,7 @@ msglist(void) { size_t i; - for (i = 0; i < sizeof msgs / sizeof msgs[0]; i++) + for (i = 0; i < sizeof(msgs) / sizeof(msgs[0]); i++) printf("%zu\t%s\n", i, msgs[i]); } diff --git a/usr.bin/xlint/lint1/func.c b/usr.bin/xlint/lint1/func.c index 72638fdd1ddf..0ab447b0b114 100644 --- a/usr.bin/xlint/lint1/func.c +++ b/usr.bin/xlint/lint1/func.c @@ -1,4 +1,4 @@ -/* $NetBSD: func.c,v 1.100 2021/04/02 11:53:25 rillig Exp $ */ +/* $NetBSD: func.c,v 1.101 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: func.c,v 1.100 2021/04/02 11:53:25 rillig Exp $"); +__RCSID("$NetBSD: func.c,v 1.101 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -157,7 +157,7 @@ begin_control_statement(control_statement_kind kind) { cstk_t *ci; - ci = xcalloc(1, sizeof *ci); + ci = xcalloc(1, sizeof(*ci)); ci->c_kind = kind; ci->c_surrounding = cstmt; cstmt = ci; @@ -501,7 +501,7 @@ check_case_label(tnode_t *tn, cstk_t *ci) * to the type of the switch expression */ v = constant(tn, true); - (void)memset(&nv, 0, sizeof nv); + (void)memset(&nv, 0, sizeof(nv)); convert_constant(CASE, 0, ci->c_switch_type, &nv, v); free(v); @@ -523,7 +523,7 @@ check_case_label(tnode_t *tn, cstk_t *ci) * append the value to the list of * case values */ - cl = xcalloc(1, sizeof *cl); + cl = xcalloc(1, sizeof(*cl)); cl->cl_val = nv; cl->cl_next = ci->c_case_labels; ci->c_case_labels = cl; @@ -683,7 +683,7 @@ switch1(tnode_t *tn) * duplicated. This is not too complicated because it is * only an integer type. */ - tp = xcalloc(1, sizeof *tp); + tp = xcalloc(1, sizeof(*tp)); if (tn != NULL) { tp->t_tspec = tn->tn_type->t_tspec; if ((tp->t_is_enum = tn->tn_type->t_is_enum) != false) @@ -1049,7 +1049,7 @@ do_return(tnode_t *tn) if (tn != NULL) { /* Create a temporary node for the left side */ - ln = expr_zalloc(sizeof *ln); + ln = expr_zalloc(sizeof(*ln)); ln->tn_op = NAME; ln->tn_type = expr_dup_type(funcsym->s_type->t_subt); ln->tn_type->t_const = false; diff --git a/usr.bin/xlint/lint1/init.c b/usr.bin/xlint/lint1/init.c index cb9af886a2e7..c8b89d3537e8 100644 --- a/usr.bin/xlint/lint1/init.c +++ b/usr.bin/xlint/lint1/init.c @@ -1,4 +1,4 @@ -/* $NetBSD: init.c,v 1.189 2021/04/02 11:53:25 rillig Exp $ */ +/* $NetBSD: init.c,v 1.190 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: init.c,v 1.189 2021/04/02 11:53:25 rillig Exp $"); +__RCSID("$NetBSD: init.c,v 1.190 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -223,7 +223,7 @@ unconst_cast(const void *p) { void *r; - memcpy(&r, &p, sizeof r); + memcpy(&r, &p, sizeof(r)); return r; } @@ -383,7 +383,7 @@ check_init_expr(const type_t *tp, sym_t *sym, tnode_t *tn) struct memory_block *tmem; /* Create a temporary node for the left side. */ - ln = expr_zalloc(sizeof *ln); + ln = expr_zalloc(sizeof(*ln)); ln->tn_op = NAME; ln->tn_type = expr_dup_type(tp); ln->tn_type->t_const = false; @@ -425,7 +425,7 @@ designator_new(const char *name, size_t subscript) { struct designator *dr; - dr = xcalloc(1, sizeof *dr); + dr = xcalloc(1, sizeof(*dr)); dr->dr_name = name; dr->dr_subscript = subscript; return dr; diff --git a/usr.bin/xlint/lint1/lex.c b/usr.bin/xlint/lint1/lex.c index ae870e2c6e52..ef36931638f9 100644 --- a/usr.bin/xlint/lint1/lex.c +++ b/usr.bin/xlint/lint1/lex.c @@ -1,4 +1,4 @@ -/* $NetBSD: lex.c,v 1.21 2021/03/28 13:09:43 rillig Exp $ */ +/* $NetBSD: lex.c,v 1.22 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: lex.c,v 1.21 2021/03/28 13:09:43 rillig Exp $"); +__RCSID("$NetBSD: lex.c,v 1.22 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -273,12 +273,12 @@ add_keyword(struct kwtab *kw, int deco) name = kw->kw_name; break; case 2: - snprintf(buf, sizeof buf, "__%s", kw->kw_name); + snprintf(buf, sizeof(buf), "__%s", kw->kw_name); name = strdup(buf); break; default: lint_assert(deco == 4); - snprintf(buf, sizeof buf, "__%s__", kw->kw_name); + snprintf(buf, sizeof(buf), "__%s__", kw->kw_name); name = strdup(buf); break; } @@ -286,7 +286,7 @@ add_keyword(struct kwtab *kw, int deco) if (name == NULL) err(1, "Can't init symbol table"); - sym = getblk(sizeof *sym); + sym = getblk(sizeof(*sym)); sym->s_name = name; sym->s_keyword = kw; sym->s_value.v_quad = kw->kw_token; @@ -349,13 +349,13 @@ allocsb(void) if ((sb = sbfrlst) != NULL) { sbfrlst = sb->sb_next; #ifdef BLKDEBUG - (void)memset(sb, 0, sizeof *sb); + (void)memset(sb, 0, sizeof(*sb)); #else sb->sb_next = NULL; #endif } else { - sb = xmalloc(sizeof *sb); - (void)memset(sb, 0, sizeof *sb); + sb = xmalloc(sizeof(*sb)); + (void)memset(sb, 0, sizeof(*sb)); } return sb; } @@ -367,7 +367,7 @@ static void freesb(sbuf_t *sb) { - (void)memset(sb, ZERO, sizeof *sb); + (void)memset(sb, ZERO, sizeof(*sb)); sb->sb_next = sbfrlst; sbfrlst = sb; } @@ -394,8 +394,8 @@ hash(const char *s) v = 0; for (us = (const u_char *)s; *us != '\0'; us++) { - v = (v << sizeof v) + *us; - v ^= v >> (sizeof v * CHAR_BIT - sizeof v); + v = (v << sizeof(v)) + *us; + v ^= v >> (sizeof(v) * CHAR_BIT - sizeof(v)); } return v % HSHSIZ1; } @@ -677,7 +677,7 @@ lex_integer_constant(const char *yytext, size_t yyleng, int base) uq = (uint64_t)xsign((int64_t)uq, typ, -1); - yylval.y_val = xcalloc(1, sizeof *yylval.y_val); + yylval.y_val = xcalloc(1, sizeof(*yylval.y_val)); yylval.y_val->v_tspec = typ; yylval.y_val->v_ansiu = ansiu; yylval.y_val->v_quad = (int64_t)uq; @@ -801,7 +801,7 @@ lex_floating_constant(const char *yytext, size_t yyleng) } } - yylval.y_val = xcalloc(1, sizeof *yylval.y_val); + yylval.y_val = xcalloc(1, sizeof(*yylval.y_val)); yylval.y_val->v_tspec = typ; if (typ == FLOAT) { yylval.y_val->v_ldbl = f; @@ -857,7 +857,7 @@ lex_character_constant(void) val = cv; } - yylval.y_val = xcalloc(1, sizeof *yylval.y_val); + yylval.y_val = xcalloc(1, sizeof(*yylval.y_val)); yylval.y_val->v_tspec = INT; yylval.y_val->v_quad = val; @@ -906,7 +906,7 @@ lex_wide_character_constant(void) } } - yylval.y_val = xcalloc(1, sizeof *yylval.y_val); + yylval.y_val = xcalloc(1, sizeof(*yylval.y_val)); yylval.y_val->v_tspec = WCHAR; yylval.y_val->v_quad = wc; @@ -1194,18 +1194,18 @@ lex_comment(void) /* Read the potential keyword to keywd */ l = 0; - while (c != EOF && isupper(c) && l < sizeof keywd - 1) { + while (c != EOF && isupper(c) && l < sizeof(keywd) - 1) { keywd[l++] = (char)c; c = inpc(); } keywd[l] = '\0'; /* look for the keyword */ - for (i = 0; i < sizeof keywtab / sizeof keywtab[0]; i++) { + for (i = 0; i < sizeof(keywtab) / sizeof(keywtab[0]); i++) { if (strcmp(keywtab[i].keywd, keywd) == 0) break; } - if (i == sizeof keywtab / sizeof keywtab[0]) + if (i == sizeof(keywtab) / sizeof(keywtab[0])) goto skip_rest; /* skip whitespace after the keyword */ @@ -1215,7 +1215,7 @@ lex_comment(void) /* read the argument, if the keyword accepts one and there is one */ l = 0; if (keywtab[i].arg) { - while (c != EOF && isdigit(c) && l < sizeof arg - 1) { + while (c != EOF && isdigit(c) && l < sizeof(arg) - 1) { arg[l++] = (char)c; c = inpc(); } @@ -1314,7 +1314,7 @@ lex_string(void) /* unterminated string constant */ error(258); - strg = xcalloc(1, sizeof *strg); + strg = xcalloc(1, sizeof(*strg)); strg->st_tspec = CHAR; strg->st_len = len; strg->st_cp = s; @@ -1358,7 +1358,7 @@ lex_wide_string(void) n = 1; } - ws = xmalloc((wlen + 1) * sizeof *ws); + ws = xmalloc((wlen + 1) * sizeof(*ws)); /* convert from multibyte to wide char */ (void)mbtowc(NULL, NULL, 0); @@ -1371,7 +1371,7 @@ lex_wide_string(void) ws[wi] = 0; free(s); - strg = xcalloc(1, sizeof *strg); + strg = xcalloc(1, sizeof(*strg)); strg->st_tspec = WCHAR; strg->st_len = wlen; strg->st_wcp = ws; @@ -1426,7 +1426,7 @@ getsym(sbuf_t *sb) /* labels must always be allocated at level 1 (outermost block) */ if (symtyp == FLABEL) { - sym = getlblk(1, sizeof *sym); + sym = getlblk(1, sizeof(*sym)); s = getlblk(1, sb->sb_len + 1); (void)memcpy(s, sb->sb_name, sb->sb_len + 1); sym->s_name = s; @@ -1436,7 +1436,7 @@ getsym(sbuf_t *sb) di = di->d_next; lint_assert(di->d_ctx == AUTO); } else { - sym = getblk(sizeof *sym); + sym = getblk(sizeof(*sym)); sym->s_name = sb->sb_name; sym->s_block_level = block_level; di = dcs; @@ -1470,7 +1470,7 @@ mktempsym(type_t *t) static int n = 0; int h; char *s = getlblk(block_level, 64); - sym_t *sym = getblk(sizeof *sym); + sym_t *sym = getblk(sizeof(*sym)); (void)snprintf(s, 64, "%.8d_tmp", n++); h = hash(s); @@ -1583,7 +1583,7 @@ pushdown(const sym_t *sym) sym_t *nsym; h = hash(sym->s_name); - nsym = getblk(sizeof *nsym); + nsym = getblk(sizeof(*nsym)); lint_assert(sym->s_block_level <= block_level); nsym->s_name = sym->s_name; UNIQUE_CURR_POS(nsym->s_def_pos); diff --git a/usr.bin/xlint/lint1/main1.c b/usr.bin/xlint/lint1/main1.c index c993f7f8ef24..d2b5f817bd05 100644 --- a/usr.bin/xlint/lint1/main1.c +++ b/usr.bin/xlint/lint1/main1.c @@ -1,4 +1,4 @@ -/* $NetBSD: main1.c,v 1.41 2021/03/28 15:36:37 rillig Exp $ */ +/* $NetBSD: main1.c,v 1.42 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main1.c,v 1.41 2021/03/28 15:36:37 rillig Exp $"); +__RCSID("$NetBSD: main1.c,v 1.42 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -135,7 +135,7 @@ static const char builtins[] = "int __builtin_isnan(long double);\n" "int __builtin_copysign(long double, long double);\n" ; -static const size_t builtinlen = sizeof builtins - 1; +static const size_t builtinlen = sizeof(builtins) - 1; static FILE * gcc_builtins(void) diff --git a/usr.bin/xlint/lint1/mem1.c b/usr.bin/xlint/lint1/mem1.c index 631b7e3cc985..915c28ed7f4f 100644 --- a/usr.bin/xlint/lint1/mem1.c +++ b/usr.bin/xlint/lint1/mem1.c @@ -1,4 +1,4 @@ -/* $NetBSD: mem1.c,v 1.42 2021/04/02 10:30:35 rillig Exp $ */ +/* $NetBSD: mem1.c,v 1.43 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: mem1.c,v 1.42 2021/04/02 10:30:35 rillig Exp $"); +__RCSID("$NetBSD: mem1.c,v 1.43 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -85,7 +85,7 @@ static struct filename_replacement *filename_replacements; void add_directory_replacement(char *arg) { - struct filename_replacement *r = xmalloc(sizeof *r); + struct filename_replacement *r = xmalloc(sizeof(*r)); char *sep = strchr(arg, '='); if (sep == NULL) @@ -111,7 +111,7 @@ transform_filename(const char *name, size_t len) break; if (r == NULL) return name; - snprintf(buf, sizeof buf, "%s%s", r->repl, name + r->orig_len); + snprintf(buf, sizeof(buf), "%s%s", r->repl, name + r->orig_len); return buf; } @@ -208,7 +208,7 @@ static memory_block *xnewblk(void); static memory_block * xnewblk(void) { - memory_block *mb = xmalloc(sizeof *mb); + memory_block *mb = xmalloc(sizeof(*mb)); /* use mmap instead of malloc to avoid malloc's size overhead */ mb->start = xmapalloc(mblklen); @@ -290,7 +290,7 @@ initmem(void) pgsz = getpagesize(); mblklen = ((MBLKSIZ + pgsz - 1) / pgsz) * pgsz; - mblks = xcalloc(nmblks = ML_INC, sizeof *mblks); + mblks = xcalloc(nmblks = ML_INC, sizeof(*mblks)); } @@ -300,8 +300,8 @@ getlblk(size_t l, size_t s) { while (l >= nmblks) { - mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof *mblks); - (void)memset(&mblks[nmblks], 0, ML_INC * sizeof *mblks); + mblks = xrealloc(mblks, (nmblks + ML_INC) * sizeof(*mblks)); + (void)memset(&mblks[nmblks], 0, ML_INC * sizeof(*mblks)); nmblks += ML_INC; } return xgetblk(&mblks[l], s); @@ -349,7 +349,7 @@ expr_zalloc(size_t s) tnode_t * expr_zalloc_tnode(void) { - tnode_t *tn = expr_zalloc(sizeof *tn); + tnode_t *tn = expr_zalloc(sizeof(*tn)); tn->tn_from_system_header = in_system_header; return tn; } diff --git a/usr.bin/xlint/lint1/tree.c b/usr.bin/xlint/lint1/tree.c index 2ab980458a51..11e117b7f00b 100644 --- a/usr.bin/xlint/lint1/tree.c +++ b/usr.bin/xlint/lint1/tree.c @@ -1,4 +1,4 @@ -/* $NetBSD: tree.c,v 1.258 2021/04/02 11:53:25 rillig Exp $ */ +/* $NetBSD: tree.c,v 1.259 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: tree.c,v 1.258 2021/04/02 11:53:25 rillig Exp $"); +__RCSID("$NetBSD: tree.c,v 1.259 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -150,7 +150,7 @@ derive_type(type_t *tp, tspec_t t) { type_t *tp2; - tp2 = getblk(sizeof *tp2); + tp2 = getblk(sizeof(*tp2)); tp2->t_tspec = t; tp2->t_subt = tp; return tp2; @@ -165,7 +165,7 @@ expr_derive_type(type_t *tp, tspec_t t) { type_t *tp2; - tp2 = expr_zalloc(sizeof *tp2); + tp2 = expr_zalloc(sizeof(*tp2)); tp2->t_tspec = t; tp2->t_subt = tp; return tp2; @@ -182,7 +182,7 @@ expr_new_constant(type_t *tp, val_t *v) n = expr_zalloc_tnode(); n->tn_op = CON; n->tn_type = tp; - n->tn_val = expr_zalloc(sizeof *n->tn_val); + n->tn_val = expr_zalloc(sizeof(*n->tn_val)); n->tn_val->v_tspec = tp->t_tspec; n->tn_val->v_ansiu = v->v_ansiu; n->tn_val->v_u = v->v_u; @@ -198,7 +198,7 @@ expr_new_integer_constant(tspec_t t, int64_t q) n = expr_zalloc_tnode(); n->tn_op = CON; n->tn_type = gettyp(t); - n->tn_val = expr_zalloc(sizeof *n->tn_val); + n->tn_val = expr_zalloc(sizeof(*n->tn_val)); n->tn_val->v_tspec = t; n->tn_val->v_quad = q; return n; @@ -286,7 +286,7 @@ new_name_node(sym_t *sym, int follow_token) n->tn_lvalue = true; } else { n->tn_op = CON; - n->tn_val = expr_zalloc(sizeof *n->tn_val); + n->tn_val = expr_zalloc(sizeof(*n->tn_val)); *n->tn_val = sym->s_value; } @@ -308,7 +308,7 @@ new_string_node(strg_t *strg) n->tn_type->t_dim = len + 1; n->tn_lvalue = true; - n->tn_string = expr_zalloc(sizeof *n->tn_string); + n->tn_string = expr_zalloc(sizeof(*n->tn_string)); n->tn_string->st_tspec = strg->st_tspec; n->tn_string->st_len = len; @@ -317,7 +317,7 @@ new_string_node(strg_t *strg) (void)memcpy(n->tn_string->st_cp, strg->st_cp, len + 1); free(strg->st_cp); } else { - size_t size = (len + 1) * sizeof *n->tn_string->st_wcp; + size_t size = (len + 1) * sizeof(*n->tn_string->st_wcp); n->tn_string->st_wcp = expr_zalloc(size); (void)memcpy(n->tn_string->st_wcp, strg->st_wcp, size); free(strg->st_wcp); @@ -350,9 +350,9 @@ struct_or_union_member(tnode_t *tn, op_t op, sym_t *msym) rmsym(msym); msym->s_kind = FMEMBER; msym->s_scl = MOS; - msym->s_styp = expr_zalloc(sizeof *msym->s_styp); + msym->s_styp = expr_zalloc(sizeof(*msym->s_styp)); msym->s_styp->sou_tag = expr_zalloc( - sizeof *msym->s_styp->sou_tag); + sizeof(*msym->s_styp->sou_tag)); msym->s_styp->sou_tag->s_name = unnamed; msym->s_value.v_tspec = INT; return msym; @@ -2065,7 +2065,7 @@ convert(op_t op, int arg, type_t *tp, tnode_t *tn) ntn->tn_left = tn; } else { ntn->tn_op = CON; - ntn->tn_val = expr_zalloc(sizeof *ntn->tn_val); + ntn->tn_val = expr_zalloc(sizeof(*ntn->tn_val)); convert_constant(op, arg, ntn->tn_type, ntn->tn_val, tn->tn_val); } @@ -2173,7 +2173,7 @@ check_integer_conversion(op_t op, int arg, tspec_t nt, tspec_t ot, type_t *tp, case SHL: /* suggest cast from '%s' to '%s' on op %s to ... */ warning(324, type_name(gettyp(ot)), type_name(tp), - print_tnode(opbuf, sizeof opbuf, tn)); + print_tnode(opbuf, sizeof(opbuf), tn)); break; default: break; @@ -3062,7 +3062,7 @@ fold(tnode_t *tn) uint64_t ul, ur = 0; tnode_t *cn; - v = xcalloc(1, sizeof *v); + v = xcalloc(1, sizeof(*v)); v->v_tspec = t = tn->tn_type->t_tspec; utyp = t == PTR || is_uinteger(t); @@ -3207,7 +3207,7 @@ fold_test(tnode_t *tn) bool l, r; val_t *v; - v = xcalloc(1, sizeof *v); + v = xcalloc(1, sizeof(*v)); v->v_tspec = tn->tn_type->t_tspec; lint_assert(v->v_tspec == INT || (Tflag && v->v_tspec == BOOL)); @@ -3245,7 +3245,7 @@ fold_float(tnode_t *tn) ldbl_t l, r = 0; fpe = 0; - v = xcalloc(1, sizeof *v); + v = xcalloc(1, sizeof(*v)); v->v_tspec = t = tn->tn_type->t_tspec; lint_assert(is_floating(t)); @@ -3702,7 +3702,7 @@ check_prototype_argument( tnode_t *ln; bool dowarn; - ln = xcalloc(1, sizeof *ln); + ln = xcalloc(1, sizeof(*ln)); ln->tn_type = expr_dup_type(tp); ln->tn_type->t_const = false; ln->tn_lvalue = true; @@ -3730,7 +3730,7 @@ constant(tnode_t *tn, bool required) if (tn != NULL) tn = promote(NOOP, false, tn); - v = xcalloc(1, sizeof *v); + v = xcalloc(1, sizeof(*v)); if (tn == NULL) { lint_assert(nerr != 0); diff --git a/usr.bin/xlint/lint2/chk.c b/usr.bin/xlint/lint2/chk.c index c19696603f68..fec4d2c4da2f 100644 --- a/usr.bin/xlint/lint2/chk.c +++ b/usr.bin/xlint/lint2/chk.c @@ -1,4 +1,4 @@ -/* $NetBSD: chk.c,v 1.41 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: chk.c,v 1.41 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: chk.c,v 1.42 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -1088,7 +1088,7 @@ chkrvu(hte_t *hte, sym_t *def) if (hflag == 0) return; if (hflag == 1 && bsearch(hte->h_name, ignorelist, - __arraycount(ignorelist), sizeof ignorelist[0], + __arraycount(ignorelist), sizeof(ignorelist[0]), (int (*)(const void *, const void *))strcmp) != NULL) return; diff --git a/usr.bin/xlint/lint2/emit2.c b/usr.bin/xlint/lint2/emit2.c index b53b9c8e8349..363d0b38e868 100644 --- a/usr.bin/xlint/lint2/emit2.c +++ b/usr.bin/xlint/lint2/emit2.c @@ -1,4 +1,4 @@ -/* $NetBSD: emit2.c,v 1.18 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: emit2.c,v 1.19 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -34,7 +34,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: emit2.c,v 1.18 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: emit2.c,v 1.19 2021/04/02 12:16:50 rillig Exp $"); #endif #include "lint2.h" @@ -277,7 +277,7 @@ addoutfile(short num) } if (ofl == NULL) { - ofl = *pofl = xmalloc(sizeof **pofl); + ofl = *pofl = xmalloc(sizeof(**pofl)); ofl->ofl_num = num; ofl->ofl_next = NULL; } diff --git a/usr.bin/xlint/lint2/hash.c b/usr.bin/xlint/lint2/hash.c index 7e7eb3f894e5..5244e26f0f3e 100644 --- a/usr.bin/xlint/lint2/hash.c +++ b/usr.bin/xlint/lint2/hash.c @@ -1,4 +1,4 @@ -/* $NetBSD: hash.c,v 1.14 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: hash.c,v 1.15 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: hash.c,v 1.14 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: hash.c,v 1.15 2021/04/02 12:16:50 rillig Exp $"); #endif /* @@ -66,7 +66,7 @@ _inithash(hte_t ***tablep) if (tablep == NULL) tablep = &htab; - *tablep = xcalloc(HSHSIZ2, sizeof **tablep); + *tablep = xcalloc(HSHSIZ2, sizeof(**tablep)); } /* @@ -80,8 +80,8 @@ hash(const char *s) v = 0; for (us = (const u_char *)s; *us != '\0'; us++) { - v = (v << sizeof v) + *us; - v ^= v >> (sizeof v * CHAR_BIT - sizeof v); + v = (v << sizeof(v)) + *us; + v ^= v >> (sizeof(v) * CHAR_BIT - sizeof(v)); } return v % HSHSIZ2; } @@ -109,7 +109,7 @@ _hsearch(hte_t **table, const char *s, bool mknew) return hte; /* create a new hte */ - hte = xmalloc(sizeof *hte); + hte = xmalloc(sizeof(*hte)); hte->h_name = xstrdup(s); hte->h_used = false; hte->h_def = false; diff --git a/usr.bin/xlint/lint2/main2.c b/usr.bin/xlint/lint2/main2.c index 7674bd5ba1e9..fdb93a28bddb 100644 --- a/usr.bin/xlint/lint2/main2.c +++ b/usr.bin/xlint/lint2/main2.c @@ -1,4 +1,4 @@ -/* $NetBSD: main2.c,v 1.14 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: main2.c,v 1.15 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1994, 1995 Jochen Pohl @@ -37,7 +37,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: main2.c,v 1.14 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: main2.c,v 1.15 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -98,7 +98,7 @@ main(int argc, char *argv[]) size_t len; char *lname; - libs = xcalloc(1, sizeof *libs); + libs = xcalloc(1, sizeof(*libs)); opterr = 0; while ((c = getopt(argc, argv, "hpstxuC:HTFl:")) != -1) { @@ -141,7 +141,7 @@ main(int argc, char *argv[]) case 'l': for (i = 0; libs[i] != NULL; i++) continue; - libs = xrealloc(libs, (i + 2) * sizeof *libs); + libs = xrealloc(libs, (i + 2) * sizeof(*libs)); libs[i] = xstrdup(optarg); libs[i + 1] = NULL; break; diff --git a/usr.bin/xlint/lint2/read.c b/usr.bin/xlint/lint2/read.c index 18714e9fe7f1..dc50b31a6a4e 100644 --- a/usr.bin/xlint/lint2/read.c +++ b/usr.bin/xlint/lint2/read.c @@ -1,4 +1,4 @@ -/* $NetBSD: read.c,v 1.41 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: read.c,v 1.42 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: read.c,v 1.41 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: read.c,v 1.42 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -119,15 +119,15 @@ readfile(const char *name) pos_t pos; if (inpfns == NULL) - inpfns = xcalloc(ninpfns = 128, sizeof *inpfns); + inpfns = xcalloc(ninpfns = 128, sizeof(*inpfns)); if (fnames == NULL) - fnames = xcalloc(nfnames = 256, sizeof *fnames); + fnames = xcalloc(nfnames = 256, sizeof(*fnames)); if (flines == NULL) - flines = xcalloc(nfnames, sizeof *flines); + flines = xcalloc(nfnames, sizeof(*flines)); if (tlstlen == 0) - tlst = xcalloc(tlstlen = 256, sizeof *tlst); + tlst = xcalloc(tlstlen = 256, sizeof(*tlst)); if (thtab == NULL) - thtab = xcalloc(THSHSIZ2, sizeof *thtab); + thtab = xcalloc(THSHSIZ2, sizeof(*thtab)); _inithash(&renametab); @@ -224,7 +224,7 @@ inperror(const char *file, size_t line, const char *fmt, ...) char buf[1024]; va_start(ap, fmt); - (void)vsnprintf(buf, sizeof buf, fmt, ap); + (void)vsnprintf(buf, sizeof(buf), fmt, ap); va_end(ap); errx(1, "%s,%zu: input file error: %s,%zu (%s)", file, line, @@ -256,8 +256,8 @@ setfnid(int fid, const char *cp) inperr("bad fid"); if ((size_t)fid >= ninpfns) { - inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof *inpfns); - (void)memset(inpfns + ninpfns, 0, ninpfns * sizeof *inpfns); + inpfns = xrealloc(inpfns, (ninpfns * 2) * sizeof(*inpfns)); + (void)memset(inpfns + ninpfns, 0, ninpfns * sizeof(*inpfns)); ninpfns *= 2; } /* @@ -282,7 +282,7 @@ funccall(pos_t *posp, const char *cp) fcall_t *fcall; const char *name; - fcall = xalloc(sizeof *fcall); + fcall = xalloc(sizeof(*fcall)); fcall->f_pos = *posp; /* read flags */ @@ -310,7 +310,7 @@ funccall(pos_t *posp, const char *cp) case 'p': case 'n': case 's': - ai = xalloc(sizeof *ai); + ai = xalloc(sizeof(*ai)); ai->a_num = (int)strtol(cp, &eptr, 10); if (cp == eptr) inperr("bad number: %s", cp); @@ -365,7 +365,7 @@ decldef(pos_t *posp, const char *cp) hte_t *hte, *renamehte = NULL; const char *name, *newname; - (void)memset(&sym, 0, sizeof sym); + (void)memset(&sym, 0, sizeof(sym)); sym.s_pos = *posp; sym.s_def = NODECL; @@ -501,10 +501,10 @@ decldef(pos_t *posp, const char *cp) if (symp == NULL) { /* allocsym does not reserve space for s_nva */ if (sym.s_va || sym.s_prfl || sym.s_scfl) { - symp = xalloc(sizeof *symp); + symp = xalloc(sizeof(*symp)); *symp = sym; } else { - symp = xalloc(sizeof symp->s_s); + symp = xalloc(sizeof(symp->s_s)); symp->s_s = sym.s_s; } *hte->h_lsym = symp; @@ -529,7 +529,7 @@ usedsym(pos_t *posp, const char *cp) hte_t *hte; const char *name; - usym = xalloc(sizeof *usym); + usym = xalloc(sizeof(*usym)); usym->u_pos = *posp; /* needed as delimiter between two numbers */ @@ -572,7 +572,7 @@ inptype(const char *cp, const char **epp) } /* No, we must create a new type. */ - tp = xalloc(sizeof *tp); + tp = xalloc(sizeof(*tp)); tidx = storetyp(tp, cp, tlen, h); @@ -664,7 +664,7 @@ inptype(const char *cp, const char **epp) narg = (int)strtol(cp, &eptr, 10); cp = eptr; tp->t_args = xcalloc((size_t)(narg + 1), - sizeof *tp->t_args); + sizeof(*tp->t_args)); for (i = 0; i < narg; i++) { if (i == narg - 1 && *cp == 'E') { tp->t_vararg = true; @@ -1008,8 +1008,8 @@ storetyp(type_t *tp, const char *cp, size_t len, int h) errx(1, "sorry, too many types"); if (tidx == tlstlen - 1) { - tlst = xrealloc(tlst, (tlstlen * 2) * sizeof *tlst); - (void)memset(tlst + tlstlen, 0, tlstlen * sizeof *tlst); + tlst = xrealloc(tlst, (tlstlen * 2) * sizeof(*tlst)); + (void)memset(tlst + tlstlen, 0, tlstlen * sizeof(*tlst)); tlstlen *= 2; } @@ -1020,7 +1020,7 @@ storetyp(type_t *tp, const char *cp, size_t len, int h) (void)memcpy(name, cp, len); name[len] = '\0'; - thte = xalloc(sizeof *thte); + thte = xalloc(sizeof(*thte)); thte->th_name = name; thte->th_idx = tidx; thte->th_next = thtab[h]; @@ -1039,8 +1039,8 @@ thash(const char *s, size_t len) v = 0; while (len-- != 0) { - v = (v << sizeof v) + (u_char)*s++; - v ^= v >> (sizeof v * CHAR_BIT - sizeof v); + v = (v << sizeof(v)) + (u_char)*s++; + v ^= v >> (sizeof(v) * CHAR_BIT - sizeof(v)); } return v % THSHSIZ2; } @@ -1174,10 +1174,10 @@ getfnidx(const char *fn) if (i == nfnames - 1) { size_t nlen = nfnames * 2; - fnames = xrealloc(fnames, nlen * sizeof *fnames); - (void)memset(fnames + nfnames, 0, nfnames * sizeof *fnames); - flines = xrealloc(flines, nlen * sizeof *flines); - (void)memset(flines + nfnames, 0, nfnames * sizeof *flines); + fnames = xrealloc(fnames, nlen * sizeof(*fnames)); + (void)memset(fnames + nfnames, 0, nfnames * sizeof(*fnames)); + flines = xrealloc(flines, nlen * sizeof(*flines)); + (void)memset(flines + nfnames, 0, nfnames * sizeof(*flines)); nfnames = nlen; } @@ -1236,7 +1236,7 @@ mkstatic(hte_t *hte) */ for (nhte = hte; nhte->h_link != NULL; nhte = nhte->h_link) continue; - nhte->h_link = xmalloc(sizeof *nhte->h_link); + nhte->h_link = xmalloc(sizeof(*nhte->h_link)); nhte = nhte->h_link; nhte->h_name = hte->h_name; nhte->h_used = true; diff --git a/usr.bin/xlint/xlint/xlint.c b/usr.bin/xlint/xlint/xlint.c index c764590bc439..43e5236ffe61 100644 --- a/usr.bin/xlint/xlint/xlint.c +++ b/usr.bin/xlint/xlint/xlint.c @@ -1,4 +1,4 @@ -/* $NetBSD: xlint.c,v 1.57 2021/03/26 20:31:07 rillig Exp $ */ +/* $NetBSD: xlint.c,v 1.58 2021/04/02 12:16:50 rillig Exp $ */ /* * Copyright (c) 1996 Christopher G. Demetriou. All Rights Reserved. @@ -38,7 +38,7 @@ #include #if defined(__RCSID) && !defined(lint) -__RCSID("$NetBSD: xlint.c,v 1.57 2021/03/26 20:31:07 rillig Exp $"); +__RCSID("$NetBSD: xlint.c,v 1.58 2021/04/02 12:16:50 rillig Exp $"); #endif #include @@ -158,7 +158,7 @@ appstrg(char ***lstp, char *s) olst = *lstp; for (i = 0; olst[i] != NULL; i++) continue; - lst = xrealloc(olst, (i + 2) * sizeof *lst); + lst = xrealloc(olst, (i + 2) * sizeof(*lst)); lst[i] = s; lst[i + 1] = NULL; *lstp = lst; @@ -182,7 +182,7 @@ applst(char ***destp, char *const *src) continue; for (k = 0; src[k] != NULL; k++) continue; - dest = xrealloc(odest, (i + k + 1) * sizeof *dest); + dest = xrealloc(odest, (i + k + 1) * sizeof(*dest)); for (k = 0; src[k] != NULL; k++) dest[i + k] = xstrdup(src[k]); dest[i + k] = NULL; @@ -322,7 +322,7 @@ main(int argc, char *argv[]) tmpdir = p; } - cppout = xmalloc(strlen(tmpdir) + sizeof "lint0.XXXXXX"); + cppout = xmalloc(strlen(tmpdir) + sizeof("lint0.XXXXXX")); (void)sprintf(cppout, "%slint0.XXXXXX", tmpdir); cppoutfd = mkstemp(cppout); if (cppoutfd == -1) { @@ -330,16 +330,16 @@ main(int argc, char *argv[]) terminate(-1); } - p1out = xcalloc(1, sizeof *p1out); - p2in = xcalloc(1, sizeof *p2in); - cflags = xcalloc(1, sizeof *cflags); - lcflags = xcalloc(1, sizeof *lcflags); - l1flags = xcalloc(1, sizeof *l1flags); - l2flags = xcalloc(1, sizeof *l2flags); - l2libs = xcalloc(1, sizeof *l2libs); - deflibs = xcalloc(1, sizeof *deflibs); - libs = xcalloc(1, sizeof *libs); - libsrchpath = xcalloc(1, sizeof *libsrchpath); + p1out = xcalloc(1, sizeof(*p1out)); + p2in = xcalloc(1, sizeof(*p2in)); + cflags = xcalloc(1, sizeof(*cflags)); + lcflags = xcalloc(1, sizeof(*lcflags)); + l1flags = xcalloc(1, sizeof(*l1flags)); + l2flags = xcalloc(1, sizeof(*l2flags)); + l2libs = xcalloc(1, sizeof(*l2libs)); + deflibs = xcalloc(1, sizeof(*deflibs)); + libs = xcalloc(1, sizeof(*libs)); + libsrchpath = xcalloc(1, sizeof(*libsrchpath)); appcstrg(&cflags, "-E"); appcstrg(&cflags, "-x"); @@ -481,7 +481,7 @@ main(int argc, char *argv[]) usage(); Cflag = true; appstrg(&l2flags, concat2("-C", optarg)); - p2out = xmalloc(sizeof "llib-l.ln" + strlen(optarg)); + p2out = xmalloc(sizeof("llib-l.ln") + strlen(optarg)); (void)sprintf(p2out, "llib-l%s.ln", optarg); freelst(&deflibs); break; @@ -674,7 +674,7 @@ fname(const char *name) if (!iflag) appcstrg(&p1out, ofn); - args = xcalloc(1, sizeof *args); + args = xcalloc(1, sizeof(*args)); /* run cc */ if ((CC = getenv("CC")) == NULL) @@ -709,7 +709,7 @@ fname(const char *name) /* run lint1 */ if (!Bflag) { - pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof "/lint1" + + pathname = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint1") + strlen(target_prefix)); (void)sprintf(pathname, "%s/%slint1", PATH_LIBEXEC, target_prefix); @@ -718,7 +718,7 @@ fname(const char *name) * XXX Unclear whether we should be using target_prefix * XXX here. --thorpej@wasabisystems.com */ - pathname = xmalloc(strlen(libexec_path) + sizeof "/lint1"); + pathname = xmalloc(strlen(libexec_path) + sizeof("/lint1")); (void)sprintf(pathname, "%s/lint1", libexec_path); } @@ -806,11 +806,11 @@ findlibs(char *const *liblst) for (i = 0; (lib = liblst[i]) != NULL; i++) { for (k = 0; (path = libsrchpath[k]) != NULL; k++) { len = strlen(path) + strlen(lib); - lfn = xrealloc(lfn, len + sizeof "/llib-l.ln"); + lfn = xrealloc(lfn, len + sizeof("/llib-l.ln")); (void)sprintf(lfn, "%s/llib-l%s.ln", path, lib); if (rdok(lfn)) break; - lfn = xrealloc(lfn, len + sizeof "/lint/llib-l.ln"); + lfn = xrealloc(lfn, len + sizeof("/lint/llib-l.ln")); (void)sprintf(lfn, "%s/lint/llib-l%s.ln", path, lib); if (rdok(lfn)) break; @@ -844,10 +844,10 @@ lint2(void) { char *path, **args; - args = xcalloc(1, sizeof *args); + args = xcalloc(1, sizeof(*args)); if (!Bflag) { - path = xmalloc(strlen(PATH_LIBEXEC) + sizeof "/lint2" + + path = xmalloc(strlen(PATH_LIBEXEC) + sizeof("/lint2") + strlen(target_prefix)); (void)sprintf(path, "%s/%slint2", PATH_LIBEXEC, target_prefix); @@ -856,7 +856,7 @@ lint2(void) * XXX Unclear whether we should be using target_prefix * XXX here. --thorpej@wasabisystems.com */ - path = xmalloc(strlen(libexec_path) + sizeof "/lint2"); + path = xmalloc(strlen(libexec_path) + sizeof("/lint2")); (void)sprintf(path, "%s/lint2", libexec_path); }