summary refs log tree commit diff
path: root/msg_socket
Commit message (Collapse)AuthorAge
...
* error: Print errors using Display implDavid Tolnay2019-02-20
| | | | | | | | | | | | | | | | | | | | | | | | | I have been running into Debug-printed error messages too often and needing to look up in the source code each level of nested errors to find out from the comment on the error variant what the short name of the variant means in human terms. Worse, many errors (like the one shown below) already had error strings written but were being printed from the calling code in the less helpful Debug representation anyway. Before: [ERROR:src/main.rs:705] The architecture failed to build the vm: NoVarEmpty After: [ERROR:src/main.rs:705] The architecture failed to build the vm: /var/empty doesn't exist, can't jail devices. TEST=cargo check --all-features TEST=FEATURES=test emerge-amd64-generic crosvm Change-Id: I77122c7d6861b2d610de2fff718896918ab21e10 Reviewed-on: https://chromium-review.googlesource.com/1469225 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Tested-by: kokoro <noreply+kokoro@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* toolchain: Update to Rust 1.31.0David Tolnay2018-12-13
| | | | | | | | | | | | | | | | | | We updated the production toolchain from 1.30 to 1.31 in CL:1366446. This CL does the same upgrade for the local developer toolchain and Kokoro. The relevant changes are in rust-toolchain and kokoro/Dockerfile. The rest are from rustfmt. TEST=cargo fmt --all -- --check TEST=as described in kokoro/README.md Change-Id: I3b4913f3e237baa36c664b4953be360c09efffd4 Reviewed-on: https://chromium-review.googlesource.com/1374376 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* lint: Resolve the easier clippy lintsDavid Tolnay2018-12-03
| | | | | | | | | | | | | | | | | | | | Hopefully the changes are self-explanatory and uncontroversial. This eliminates much of the noise from `cargo clippy` and, for my purposes, gives me a reasonable way to use it as a tool when writing and reviewing code. Here is the Clippy invocation I was using: cargo +nightly clippy -- -W clippy::correctness -A renamed_and_removed_lints -Aclippy::{blacklisted_name,borrowed_box,cast_lossless,cast_ptr_alignment,enum_variant_names,identity_op,if_same_then_else,mut_from_ref,needless_pass_by_value,new_without_default,new_without_default_derive,or_fun_call,ptr_arg,should_implement_trait,single_match,too_many_arguments,trivially_copy_pass_by_ref,unreadable_literal,unsafe_vector_initialization,useless_transmute} TEST=cargo check --features wl-dmabuf,gpu,usb-emulation TEST=boot linux Change-Id: I55eb1b4a72beb2f762480e3333a921909314a0a2 Reviewed-on: https://chromium-review.googlesource.com/1356911 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Dylan Reid <dgreid@chromium.org>
* msg_socket: reformat with rust fmtDaniel Verkamp2018-11-22
| | | | | | | | | | | TEST=cargo fmt -- --check BUG=None Change-Id: I489def320a27336dd85743f7bf5b944756425c52 Signed-off-by: Daniel Verkamp <dverkamp@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/1347009 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Reviewed-by: Jingkui Wang <jkwang@google.com>
* msg_socket: fix msg_on_socket alignment issueJingkui Wang2018-11-21
| | | | | | | | | | | | | | | Instead of using unaligned memory. Allocate aligned memory and copy into it, we were already doing an clone. There should be no overhead for this new approach. BUG=chromium:900962 TEST=build and run Change-Id: I011d4c93a872d7d285e8898ff332f3ee1ef104a9 Reviewed-on: https://chromium-review.googlesource.com/1344225 Commit-Ready: Jingkui Wang <jkwang@google.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* macros: Format code inside of quote! invocationsDavid Tolnay2018-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Rustfmt currently does not touch the content of macro invocations. Also it used to have a bug where if it changed indentation of a block of code containing a multi-line macro invocation then the macro input would not get correspondingly indented. That bug was visible across some of the code here. For example: // rustfmt decides to un-indent the surrounding block: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); // poorly formatted resulting code: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); // should have been: let data_size_in_bytes = quote!( ( #( #field_types::FIELD_WIDTH as usize )+* ) / 8 ); TEST=cargo check crosvm TEST=cargo test each of the three proc-macro crates CQ-DEPEND=CL:1338507 Change-Id: Id2d456a8d85d719fbc0a65624f153f0f9df6f500 Reviewed-on: https://chromium-review.googlesource.com/1338508 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* macros: Update syn to 0.15David Tolnay2018-11-21
| | | | | | | | | | | | | | | | | | | | | | | | | This brings us onto the stable API surface area for procedural macros that stabilized in Rust 1.30, rather than the string-based shim on older compilers. https://blog.rust-lang.org/2018/10/25/Rust-1.30.0.html Intervening release notes: - https://github.com/dtolnay/syn/releases/tag/0.13.0 - https://github.com/dtolnay/syn/releases/tag/0.14.0 - https://github.com/dtolnay/syn/releases/tag/0.15.0 TEST=cargo check crosvm TEST=cargo test each of the three proc-macro crates TEST=build_packages CQ-DEPEND=CL:1340766 Change-Id: Idcf14df0225ab41423b9a8639d0bba0a63513712 Reviewed-on: https://chromium-review.googlesource.com/1338507 Commit-Ready: David Tolnay <dtolnay@chromium.org> Tested-by: David Tolnay <dtolnay@chromium.org> Reviewed-by: Chirantan Ekbote <chirantan@chromium.org>
* msg_socket: return io:Error from pair() instead of OptionZach Reizner2018-11-15
| | | | | | | | Change-Id: I8733794bca7a9510d5508941cbe3297a78e9923b Reviewed-on: https://chromium-review.googlesource.com/1314210 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Zach Reizner <zachr@chromium.org>
* msg_socket: implement AsRawFd for UnixDatagram wrappersZach Reizner2018-11-15
| | | | | | | | Change-Id: I0589c6b88b4922db422771dc5930ca3f00b91736 Reviewed-on: https://chromium-review.googlesource.com/1314209 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* fix formatting in msg_on_socket_derive.rs unit testZach Reizner2018-11-09
| | | | | | | | | | | | | | | Turns out my cargo-fmt binary was being sourced from ~/.cargo/bin, which was very out of date. Hopefully less formatting issues come out of my chroot now. TEST=cargo fmt --all -- --check BUG=None Change-Id: I50592e2781835840dc5d589c681b3438d6de3370 Reviewed-on: https://chromium-review.googlesource.com/1324669 Commit-Ready: Zach Reizner <zachr@chromium.org> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Daniel Verkamp <dverkamp@chromium.org>
* msg_socket_on_derive: use fully qualified typesZach Reizner2018-11-07
| | | | | | | | | | | | | | | | | | | | | | The types from msg_socket were assumed to be in scope for the custom derive implementation, which would cause mysterious compiler errors if the custom derive was invoked in a module without msg_socket types in scope. This CL uses fully qualified types in the generated output to avoid these errors. This change also uses `extern crate msg_socket` in case the call site doesn't have it in scope. BUG=None TEST=cargo test -p msg_on_socket_derive Change-Id: Ie6443cd4ffc070d27e71de123090a58f19846472 Reviewed-on: https://chromium-review.googlesource.com/1314208 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Zach Reizner <zachr@chromium.org> Reviewed-by: Jingkui Wang <jkwang@google.com>
* msg_socket: avoid send_msg/recv_msg call if it's not necessaryJingkui Wang2018-11-02
| | | | | | | | | | | | | This patch avoids sendmsg/recvmsg if there is no fd. BUG=chromium:900962 TEST=build local image and test Change-Id: I3a5fd52232dc7d98dacd78aa0b383a436056ffb7 Reviewed-on: https://chromium-review.googlesource.com/1313656 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>
* crosvm: add msg_sock.Jingkui Wang2018-10-09
MsgSock wraps UnixDatagram and provides simple macro to define Messages that could be send through sock easily. TEST=cargo test BUG=None Change-Id: I296fabc41893ad6a3ec42ef82dd29c3b752be8b8 Reviewed-on: https://chromium-review.googlesource.com/1255548 Commit-Ready: ChromeOS CL Exonerator Bot <chromiumos-cl-exonerator@appspot.gserviceaccount.com> Tested-by: Jingkui Wang <jkwang@google.com> Reviewed-by: Zach Reizner <zachr@chromium.org>