Skip to content

Commit 812010b

Browse files
dianpopaacatangiu
authored andcommitted
rustfmt: update CI logic to use newly...
added '--check' flag and fix cargo fmt's output. Signed-off-by: Diana Popa <[email protected]>
1 parent 4a38e2a commit 812010b

File tree

14 files changed

+170
-154
lines changed

14 files changed

+170
-154
lines changed

api_server/src/http_service.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -751,10 +751,11 @@ mod tests {
751751
};
752752

753753
fn body_to_string(body: hyper::Body) -> String {
754-
let ret = body.fold(Vec::new(), |mut acc, chunk| {
755-
acc.extend_from_slice(&*chunk);
756-
Ok::<_, hyper::Error>(acc)
757-
}).and_then(move |value| Ok(value));
754+
let ret =
755+
body.fold(Vec::new(), |mut acc, chunk| {
756+
acc.extend_from_slice(&*chunk);
757+
Ok::<_, hyper::Error>(acc)
758+
}).and_then(move |value| Ok(value));
758759

759760
String::from_utf8_lossy(&ret.wait().unwrap()).into()
760761
}

api_server/src/request/sync/drive.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -213,11 +213,14 @@ mod tests {
213213

214214
assert!(&desc.clone().into_parsed_request("bar").is_err());
215215
let (sender, receiver) = oneshot::channel();
216-
assert!(&desc.clone()
217-
.into_parsed_request("foo")
218-
.eq(&Ok(ParsedRequest::Sync(
219-
SyncRequest::PutDrive(desc, sender),
220-
receiver
221-
))));
216+
assert!(
217+
&desc
218+
.clone()
219+
.into_parsed_request("foo")
220+
.eq(&Ok(ParsedRequest::Sync(
221+
SyncRequest::PutDrive(desc, sender),
222+
receiver
223+
)))
224+
);
222225
}
223226
}

api_server/src/request/sync/logger.rs

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,11 +119,14 @@ mod tests {
119119
format!("{:?}", desc);
120120
assert!(&desc.clone().into_parsed_request().is_ok());
121121
let (sender, receiver) = oneshot::channel();
122-
assert!(&desc.clone()
123-
.into_parsed_request()
124-
.eq(&Ok(ParsedRequest::Sync(
125-
SyncRequest::PutLogger(desc, sender),
126-
receiver
127-
))));
122+
assert!(
123+
&desc
124+
.clone()
125+
.into_parsed_request()
126+
.eq(&Ok(ParsedRequest::Sync(
127+
SyncRequest::PutLogger(desc, sender),
128+
receiver
129+
)))
130+
);
128131
}
129132
}

devices/src/virtio/block.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,8 @@ enum RequestType {
8888
}
8989

9090
fn request_type(mem: &GuestMemory, desc_addr: GuestAddress) -> result::Result<RequestType, Error> {
91-
let type_ = mem.read_obj_from_addr(desc_addr)
91+
let type_ = mem
92+
.read_obj_from_addr(desc_addr)
9293
.map_err(Error::GuestMemory)?;
9394
match type_ {
9495
VIRTIO_BLK_T_IN => Ok(RequestType::In),
@@ -246,7 +247,8 @@ impl BlockEpollHandler {
246247
{
247248
// If limiter.consume() fails it means there is no more TokenType::Bytes
248249
// budget and rate limiting is in effect.
249-
if !self.rate_limiter
250+
if !self
251+
.rate_limiter
250252
.consume(request.data_len as u64, TokenType::Bytes)
251253
{
252254
rate_limited = true;

devices/src/virtio/net.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,8 @@ impl NetEpollHandler {
152152
}
153153
// If limiter.consume() fails it means there is no more TokenType::Bytes
154154
// budget and rate limiting is in effect.
155-
if !self.rx
155+
if !self
156+
.rx
156157
.rate_limiter
157158
.consume(self.rx.bytes_read as u64, TokenType::Bytes)
158159
{
@@ -324,7 +325,8 @@ impl NetEpollHandler {
324325

325326
// If limiter.consume() fails it means there is no more TokenType::Bytes
326327
// budget and rate limiting is in effect.
327-
if !self.tx
328+
if !self
329+
.tx
328330
.rate_limiter
329331
.consume(read_count as u64, TokenType::Bytes)
330332
{

devices/src/virtio/queue.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ impl<'a> DescriptorChain<'a> {
106106
}
107107

108108
fn is_valid(&self) -> bool {
109-
if self.mem
109+
if self
110+
.mem
110111
.checked_offset(self.addr, self.len as usize)
111112
.is_none() || (self.has_next() && self.next >= self.queue_size)
112113
{

jailer/src/lib.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ impl<'a> JailerArgs<'a> {
8181
// Check that id meets the style of an UUID's.
8282
validate(id).map_err(Error::ValidateUUID)?;
8383

84-
let numa_node = node.parse::<u32>()
84+
let numa_node = node
85+
.parse::<u32>()
8586
.map_err(|_| Error::NumaNode(String::from(node)))?;
8687

8788
let exec_file_path =
@@ -104,9 +105,11 @@ impl<'a> JailerArgs<'a> {
104105
return Err(Error::NotAFolder(chroot_base_dir));
105106
}
106107

107-
let uid = uid.parse::<u32>()
108+
let uid = uid
109+
.parse::<u32>()
108110
.map_err(|_| Error::Uid(String::from(uid)))?;
109-
let gid = gid.parse::<u32>()
111+
let gid = gid
112+
.parse::<u32>()
110113
.map_err(|_| Error::Gid(String::from(gid)))?;
111114

112115
Ok(JailerArgs {
@@ -213,7 +216,8 @@ pub fn run(args: JailerArgs) -> Result<()> {
213216
/// The expect should not fail, since Linux paths only contain valid Unicode chars (do they?),
214217
/// and do not contain null bytes (do they?).
215218
pub fn into_cstring(path: PathBuf) -> Result<CString> {
216-
let path_str = path.clone()
219+
let path_str = path
220+
.clone()
217221
.into_os_string()
218222
.into_string()
219223
.map_err(|e| Error::OsStringParsing(path, e))?;

kvm/src/lib.rs

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1006,24 +1006,13 @@ mod tests {
10061006

10071007
// This example based on https://lwn.net/Articles/658511/
10081008
let code = [
1009-
0xba,
1010-
0xf8,
1011-
0x03, /* mov $0x3f8, %dx */
1012-
0x00,
1013-
0xd8, /* add %bl, %al */
1014-
0x04,
1015-
'0' as u8, /* add $'0', %al */
1009+
0xba, 0xf8, 0x03, /* mov $0x3f8, %dx */
1010+
0x00, 0xd8, /* add %bl, %al */
1011+
0x04, '0' as u8, /* add $'0', %al */
10161012
0xee, /* out %al, %dx */
10171013
0xec, /* in %dx, %al */
1018-
0xc6,
1019-
0x06,
1020-
0x00,
1021-
0x20,
1022-
0x00, /* movl $0, (0x2000) */
1023-
0x8a,
1024-
0x16,
1025-
0x00,
1026-
0x20, /* movl (0x2000), %dl */
1014+
0xc6, 0x06, 0x00, 0x20, 0x00, /* movl $0, (0x2000) */
1015+
0x8a, 0x16, 0x00, 0x20, /* movl (0x2000), %dl */
10271016
0xf4, /* hlt */
10281017
];
10291018

sys_util/src/guest_memory.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,8 @@ impl GuestMemory {
5252
let mut regions = Vec::<MemoryRegion>::new();
5353
for range in ranges.iter() {
5454
if let Some(last) = regions.last() {
55-
if last.guest_base
55+
if last
56+
.guest_base
5657
.checked_add(last.mapping.size())
5758
.map_or(true, |a| a > range.0)
5859
{

tests/build/test_style.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def test_style():
3838
install_rustfmt_if_needed()
3939

4040
process = run(
41-
'cargo fmt --all -- --write-mode=diff',
41+
'cargo fmt --all -- --check',
4242
shell=True,
4343
check=True,
4444
stdout=PIPE

0 commit comments

Comments
 (0)