[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v2 35/48] bsd-user: style tweak: use {} for all if statements, fo
From: |
imp |
Subject: |
[PATCH v2 35/48] bsd-user: style tweak: use {} for all if statements, format else correctly |
Date: |
Sat, 24 Apr 2021 10:00:03 -0600 |
From: Warner Losh <imp@bsdimp.com>
Signed-off-by: Warner Losh <imp@bsdimp.com>
---
bsd-user/qemu.h | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/bsd-user/qemu.h b/bsd-user/qemu.h
index 2494d9209d..8d3767964d 100644
--- a/bsd-user/qemu.h
+++ b/bsd-user/qemu.h
@@ -358,16 +358,18 @@ abi_long copy_to_user(abi_ulong gaddr, void *hptr, size_t
len);
static inline void *lock_user(int type, abi_ulong guest_addr, long len,
int copy)
{
- if (!access_ok(type, guest_addr, len))
+ if (!access_ok(type, guest_addr, len)) {
return NULL;
+ }
#ifdef DEBUG_REMAP
{
void *addr;
addr = g_malloc(len);
- if (copy)
+ if (copy) {
memcpy(addr, g2h_untagged(guest_addr), len);
- else
+ } else {
memset(addr, 0, len);
+ }
return addr;
}
#else
@@ -384,12 +386,15 @@ static inline void unlock_user(void *host_ptr, abi_ulong
guest_addr,
{
#ifdef DEBUG_REMAP
- if (!host_ptr)
+ if (!host_ptr) {
return;
- if (host_ptr == g2h_untagged(guest_addr))
+ }
+ if (host_ptr == g2h_untagged(guest_addr)) {
return;
- if (len > 0)
+ }
+ if (len > 0) {
memcpy(g2h_untagged(guest_addr), host_ptr, len);
+ }
g_free(host_ptr);
#endif
}
@@ -405,8 +410,9 @@ static inline void *lock_user_string(abi_ulong guest_addr)
{
abi_long len;
len = target_strlen(guest_addr);
- if (len < 0)
+ if (len < 0) {
return NULL;
+ }
return lock_user(VERIFY_READ, guest_addr, (long)(len + 1), 1);
}
--
2.22.1
- Re: [PATCH v2 42/48] bsd-user: style tweak: spaces around operators and commas, (continued)
- [PATCH v2 38/48] bsd-user: style tweak: use {} for all if statements, format else correctly, imp, 2021/04/24
- [PATCH v2 44/48] bsd-user: style tweak: use preferred block comments, imp, 2021/04/24
- [PATCH v2 48/48] bsd-user: put back a break; that had gone missing..., imp, 2021/04/24
- [PATCH v2 19/48] bsd-user: style tweak: move extern to header file, imp, 2021/04/24
- [PATCH v2 27/48] bsd-user: style tweak: space pedantry, imp, 2021/04/24
- [PATCH v2 35/48] bsd-user: style tweak: use {} for all if statements, format else correctly,
imp <=
- [PATCH v2 30/48] bsd-user: style tweak: fix block comments, imp, 2021/04/24
- [PATCH v2 36/48] bsd-user: style tweak: Use preferred block comments, imp, 2021/04/24
- [PATCH v2 46/48] bsd-user: style tweak: Return is not a function call., imp, 2021/04/24
- [PATCH v2 34/48] bsd-user: style tweak: don't assign in if statements, imp, 2021/04/24
- [PATCH v2 47/48] bsd-user: style tweak: don't assign in if statement., imp, 2021/04/24