From nobody Mon Feb 9 02:13:34 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1620840761; cv=none; d=zohomail.com; s=zohoarc; b=gdbf5LT5W/rVp/fEieLws4FcpnrrtbrTZBM1zKY+qnGYpaExD3ubmjITLVri78hppTy4F92/Y+nN2f5xCJLEERZWQOd7mLn/1s0eSE1s0D6n5UPF/VF353nuzo3W5ovM/G85KSiYlsjt3cXNXuNcinT1nNICv+rUcdHzxzTdje0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1620840761; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=PTBbSYYJVsByI4TeGnQsbvTNd/mEb0R8DgVhE9PirYU=; b=EGaMjrHCxXA+wKZsHl3CqMux7tq0au7amnA6Au7H7A6oVzpzotag8Cjq9eKf9DXPo74Oi6jcHao4bMqOY55OrLSH0fySHRzNYh9c7hNGytaZmBXk3+bfyuJovWCy9ruKwqZIFWjAEsjh0RTJX0O0mjaFyR/993MFsQbH+p6IqfE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1620840761045465.85505669616714; Wed, 12 May 2021 10:32:41 -0700 (PDT) Received: from localhost ([::1]:60488 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lgsit-0006b5-Gs for importer@patchew.org; Wed, 12 May 2021 13:32:39 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59674) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lgsUe-0007EW-Ee for qemu-devel@nongnu.org; Wed, 12 May 2021 13:17:56 -0400 Received: from mail-io1-xd31.google.com ([2607:f8b0:4864:20::d31]:37733) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1lgsUO-0008LQ-Nb for qemu-devel@nongnu.org; Wed, 12 May 2021 13:17:56 -0400 Received: by mail-io1-xd31.google.com with SMTP id n40so6642185ioz.4 for ; Wed, 12 May 2021 10:17:39 -0700 (PDT) Received: from dune.bsdimp.com (50-253-99-174-static.hfc.comcastbusiness.net. [50.253.99.174]) by smtp.gmail.com with ESMTPSA id d2sm192064ile.18.2021.05.12.10.17.37 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 12 May 2021 10:17:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bsdimp-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PTBbSYYJVsByI4TeGnQsbvTNd/mEb0R8DgVhE9PirYU=; b=VyInb+1E24mve4YBnCFEddWG4iil4YY3i4IhPP3HkUWBK2T8pGAEVFSUfFX4luBPYM yJpzVPX8mTtMJF8NeKCPmOPT5gcOE8HWTlYKzMtsi4fv7rTVRTnNS6ATntzv6wMWPny4 ra2mRQjQPfnmrHd2jWqxiAKyESoZuT5MNcAmWiJrU7lBNYTGhcwJe/yFgVN/IaJIOkKV 9BOjAbmAYiGiGoBpFfQYAUaXyJkK+ji2Hq2WFBqm3WL9406x3w4XEn/2FTXxy5nLWrG9 KE3AELgVdO0kt0XU1zJItjVyfV225VxOxgChmH5lygopt9sr0EfMLwWFeDPevRHnzOT5 o2NQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PTBbSYYJVsByI4TeGnQsbvTNd/mEb0R8DgVhE9PirYU=; b=opJ8mqTsEu0v6QwnB07V9dlh+lWMRYj6pxR1aTv8s9SNa4pKn3DbUURLiuBQPa9IhF 3LMfzkI9VeT1tiRLukD8UO5+yexTRUa2dKqcu5ApWgsWrff6nEA0sEVdjsrr/1U1McWP wllDAyyBc0k6RCGLjxqdCL4qklc/sEpUHsV+XN5ycAPTBLYJcVvJECaxrPshXkjjBD8b 8CsuXfk4dpXGPO+NUpUp3Qi7giqfbrwDH24Z2ne2BhhTG8/BP+EgSMDOdON1LcqAEpwN Xrj45+Nnyt5sIeH3ORoaRy9ErNYweD4IBDc+PGF5oUtYs+Hof3g2J5HACli9HNsXgntC 1Rxw== X-Gm-Message-State: AOAM532xkI0GelMmKrULuhwOfCeDYNmbZbWBhE09hm7CaizCBMus4Jgd E8jx8VNXMr67KozDvi6I3+Wh/vl7Zm4hxA== X-Google-Smtp-Source: ABdhPJwrWtFRX0o39HdcSFCeATA2ix7g5Yct5XGMSCJ0+u5O0NuzDNka8dZakP/k7Y83fi+ODO88JQ== X-Received: by 2002:a05:6602:14d3:: with SMTP id b19mr19779112iow.154.1620839858160; Wed, 12 May 2021 10:17:38 -0700 (PDT) From: Warner Losh To: qemu-devel@nongnu.org Subject: [PULL 11/20] bsd-user: style tweak: use {} consistently in for / if / else statements Date: Wed, 12 May 2021 11:17:11 -0600 Message-Id: <20210512171720.46744-12-imp@bsdimp.com> X-Mailer: git-send-email 2.22.1 In-Reply-To: <20210512171720.46744-1-imp@bsdimp.com> References: <20210512171720.46744-1-imp@bsdimp.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: none client-ip=2607:f8b0:4864:20::d31; envelope-from=imp@bsdimp.com; helo=mail-io1-xd31.google.com X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: kevans@freebsd.org, Richard Henderson , Warner Losh Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Fix various issues with {} not being present on if / for statements. Minor line length tweaks Move an assignment in an if out. Reviewed-by: Richard Henderson Signed-off-by: Warner Losh --- bsd-user/main.c | 66 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/bsd-user/main.c b/bsd-user/main.c index 71bfe17f38..0f9e6bfbc0 100644 --- a/bsd-user/main.c +++ b/bsd-user/main.c @@ -217,7 +217,7 @@ void cpu_loop(CPUX86State *env) #ifndef TARGET_ABI32 case EXCP_SYSCALL: /* syscall from syscall instruction */ - if (bsd_type =3D=3D target_freebsd) + if (bsd_type =3D=3D target_freebsd) { env->regs[R_EAX] =3D do_freebsd_syscall(env, env->regs[R_EAX], env->regs[R_EDI], @@ -226,7 +226,7 @@ void cpu_loop(CPUX86State *env) env->regs[R_ECX], env->regs[8], env->regs[9], 0, 0); - else { /* if (bsd_type =3D=3D target_openbsd) */ + } else { /* if (bsd_type =3D=3D target_openbsd) */ env->regs[R_EAX] =3D do_openbsd_syscall(env, env->regs[R_EAX], env->regs[R_EDI], @@ -250,7 +250,8 @@ void cpu_loop(CPUX86State *env) break; default: pc =3D env->segs[R_CS].base + env->eip; - fprintf(stderr, "qemu: 0x%08lx: unhandled CPU exception 0x%x -= aborting\n", + fprintf(stderr, + "qemu: 0x%08lx: unhandled CPU exception 0x%x - abortin= g\n", (long)pc, trapnr); abort(); } @@ -274,8 +275,9 @@ static inline int get_reg_index(CPUSPARCState *env, int= cwp, int index) * wrap handling : if cwp is on the last window, then we use the * registers 'after' the end */ - if (index < 8 && env->cwp =3D=3D env->nwindows - 1) + if (index < 8 && env->cwp =3D=3D env->nwindows - 1) { index +=3D 16 * env->nwindows; + } return index; } =20 @@ -287,8 +289,9 @@ static inline void save_window_offset(CPUSPARCState *en= v, int cwp1) =20 sp_ptr =3D env->regbase[get_reg_index(env, cwp1, 6)]; #ifdef TARGET_SPARC64 - if (sp_ptr & 3) + if (sp_ptr & 3) { sp_ptr +=3D SPARC64_STACK_BIAS; + } #endif #if defined(DEBUG_WIN) printf("win_overflow: sp_ptr=3D0x" TARGET_ABI_FMT_lx " save_cwp=3D%d\n= ", @@ -337,8 +340,9 @@ static void restore_window(CPUSPARCState *env) cwp1 =3D cpu_cwp_inc(env, env->cwp + 1); sp_ptr =3D env->regbase[get_reg_index(env, cwp1, 6)]; #ifdef TARGET_SPARC64 - if (sp_ptr & 3) + if (sp_ptr & 3) { sp_ptr +=3D SPARC64_STACK_BIAS; + } #endif #if defined(DEBUG_WIN) printf("win_underflow: sp_ptr=3D0x" TARGET_ABI_FMT_lx " load_cwp=3D%d\= n", @@ -351,8 +355,9 @@ static void restore_window(CPUSPARCState *env) } #ifdef TARGET_SPARC64 env->canrestore++; - if (env->cleanwin < env->nwindows - 1) + if (env->cleanwin < env->nwindows - 1) { env->cleanwin++; + } env->cansave--; #else env->wim =3D new_wim; @@ -368,11 +373,13 @@ static void flush_windows(CPUSPARCState *env) /* if restore would invoke restore_window(), then we can stop */ cwp1 =3D cpu_cwp_inc(env, env->cwp + offset); #ifndef TARGET_SPARC64 - if (env->wim & (1 << cwp1)) + if (env->wim & (1 << cwp1)) { break; + } #else - if (env->canrestore =3D=3D 0) + if (env->canrestore =3D=3D 0) { break; + } env->cansave++; env->canrestore--; #endif @@ -407,8 +414,9 @@ void cpu_loop(CPUSPARCState *env) #else /* FreeBSD uses 0x141 for syscalls too */ case 0x141: - if (bsd_type !=3D target_freebsd) + if (bsd_type !=3D target_freebsd) { goto badtrap; + } /* fallthrough */ case 0x100: #endif @@ -417,7 +425,8 @@ void cpu_loop(CPUSPARCState *env) ret =3D do_freebsd_syscall(env, syscall_nr, env->regwptr[0], env->regwptr[1], env->regwptr[2], env->regwptr[3], - env->regwptr[4], env->regwptr[5],= 0, 0); + env->regwptr[4], env->regwptr[5], + 0, 0); else if (bsd_type =3D=3D target_netbsd) ret =3D do_netbsd_syscall(env, syscall_nr, env->regwptr[0], env->regwptr[1], @@ -610,8 +619,9 @@ int main(int argc, char **argv) envlist_t *envlist =3D NULL; bsd_type =3D target_openbsd; =20 - if (argc <=3D 1) + if (argc <=3D 1) { usage(); + } =20 error_init(argv[0]); module_call_init(MODULE_INIT_TRACE); @@ -631,11 +641,13 @@ int main(int argc, char **argv) =20 optind =3D 1; for (;;) { - if (optind >=3D argc) + if (optind >=3D argc) { break; + } r =3D argv[optind]; - if (r[0] !=3D '-') + if (r[0] !=3D '-') { break; + } optind++; r++; if (!strcmp(r, "-")) { @@ -652,24 +664,28 @@ int main(int argc, char **argv) log_file =3D argv[optind++]; } else if (!strcmp(r, "E")) { r =3D argv[optind++]; - if (envlist_setenv(envlist, r) !=3D 0) + if (envlist_setenv(envlist, r) !=3D 0) { usage(); + } } else if (!strcmp(r, "ignore-environment")) { envlist_free(envlist); envlist =3D envlist_create(); } else if (!strcmp(r, "U")) { r =3D argv[optind++]; - if (envlist_unsetenv(envlist, r) !=3D 0) + if (envlist_unsetenv(envlist, r) !=3D 0) { usage(); + } } else if (!strcmp(r, "s")) { r =3D argv[optind++]; x86_stack_size =3D strtol(r, (char **)&r, 0); - if (x86_stack_size <=3D 0) + if (x86_stack_size <=3D 0) { usage(); - if (*r =3D=3D 'M') + } + if (*r =3D=3D 'M') { x86_stack_size *=3D MiB; - else if (*r =3D=3D 'k' || *r =3D=3D 'K') + } else if (*r =3D=3D 'k' || *r =3D=3D 'K') { x86_stack_size *=3D KiB; + } } else if (!strcmp(r, "L")) { interp_prefix =3D argv[optind++]; } else if (!strcmp(r, "p")) { @@ -809,11 +825,13 @@ int main(int argc, char **argv) if (!have_guest_base) { FILE *fp; =20 - if ((fp =3D fopen("/proc/sys/vm/mmap_min_addr", "r")) !=3D NULL) { + fp =3D fopen("/proc/sys/vm/mmap_min_addr", "r"); + if (fp !=3D NULL) { unsigned long tmp; if (fscanf(fp, "%lu", &tmp) =3D=3D 1) { mmap_min_addr =3D tmp; - qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx\n"= , mmap_min_addr); + qemu_log_mask(CPU_LOG_PAGE, "host mmap_min_addr=3D0x%lx\n", + mmap_min_addr); } fclose(fp); } @@ -986,10 +1004,12 @@ int main(int argc, char **argv) env->pc =3D regs->pc; env->npc =3D regs->npc; env->y =3D regs->y; - for (i =3D 0; i < 8; i++) + for (i =3D 0; i < 8; i++) { env->gregs[i] =3D regs->u_regs[i]; - for (i =3D 0; i < 8; i++) + } + for (i =3D 0; i < 8; i++) { env->regwptr[i] =3D regs->u_regs[i + 8]; + } } #else #error unsupported target CPU --=20 2.22.1