提交 ae0cbbb1 编写于 作者: Q Quentin Lambert 提交者: Joerg Roedel

iommu/amd: Convert non-returned local variable to boolean when relevant

This patch was produced using Coccinelle. A simplified version of the
semantic patch is:

@r exists@
identifier f;
local idexpression u8 x;
identifier xname;
@@

f(...) {
...when any
(
  x@xname = 1;
|
  x@xname = 0;
)
...when any
}

@bad exists@
identifier r.f;
local idexpression u8 r.x
expression e1 != {0, 1}, e2;
@@

f(...) {
...when any
(
  x = e1;
|
  x + e2
)
...when any
}

@depends on !bad@
identifier r.f;
local idexpression u8 r.x;
identifier r.xname;
@@

f(...) {
...
++ bool xname;
- int xname;
<...
(
  x =
- 1
+ true
|
  x =
- -1
+ false
)
...>

}
Signed-off-by: NQuentin Lambert <lambert.quentin@gmail.com>
Signed-off-by: NJoerg Roedel <jroedel@suse.de>
上级 a1bec062
...@@ -843,10 +843,10 @@ static void build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address, ...@@ -843,10 +843,10 @@ static void build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address,
size_t size, u16 domid, int pde) size_t size, u16 domid, int pde)
{ {
u64 pages; u64 pages;
int s; bool s;
pages = iommu_num_pages(address, size, PAGE_SIZE); pages = iommu_num_pages(address, size, PAGE_SIZE);
s = 0; s = false;
if (pages > 1) { if (pages > 1) {
/* /*
...@@ -854,7 +854,7 @@ static void build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address, ...@@ -854,7 +854,7 @@ static void build_inv_iommu_pages(struct iommu_cmd *cmd, u64 address,
* TLB entries for this domain * TLB entries for this domain
*/ */
address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS; address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS;
s = 1; s = true;
} }
address &= PAGE_MASK; address &= PAGE_MASK;
...@@ -874,10 +874,10 @@ static void build_inv_iotlb_pages(struct iommu_cmd *cmd, u16 devid, int qdep, ...@@ -874,10 +874,10 @@ static void build_inv_iotlb_pages(struct iommu_cmd *cmd, u16 devid, int qdep,
u64 address, size_t size) u64 address, size_t size)
{ {
u64 pages; u64 pages;
int s; bool s;
pages = iommu_num_pages(address, size, PAGE_SIZE); pages = iommu_num_pages(address, size, PAGE_SIZE);
s = 0; s = false;
if (pages > 1) { if (pages > 1) {
/* /*
...@@ -885,7 +885,7 @@ static void build_inv_iotlb_pages(struct iommu_cmd *cmd, u16 devid, int qdep, ...@@ -885,7 +885,7 @@ static void build_inv_iotlb_pages(struct iommu_cmd *cmd, u16 devid, int qdep,
* TLB entries for this domain * TLB entries for this domain
*/ */
address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS; address = CMD_INV_IOMMU_ALL_PAGES_ADDRESS;
s = 1; s = true;
} }
address &= PAGE_MASK; address &= PAGE_MASK;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册