Skip to content

Commit 33fd893

Browse files
committed
feedback
1 parent 8f7c683 commit 33fd893

File tree

2 files changed

+24
-45
lines changed

2 files changed

+24
-45
lines changed

Cargo.toml

Lines changed: 8 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -147,38 +147,25 @@ members = [
147147
# This way all crates can use it with `[lints] workspace=true` section
148148

149149
[lints.rust]
150-
# FIXME(cleanup): should be cleaned up
151-
unused_imports = "allow"
152-
unused_qualifications = "allow" # make ident usage consistent in each file
150+
# FIXME(cleanup): make ident usage consistent in each file
151+
unused_qualifications = "allow"
153152

154153
[lints.clippy]
155-
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
156-
missing_safety_doc = "allow" # safety? in libc? seriously?
157-
158-
# FIXME(clippy): all these should probably be fixed
159-
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
160-
unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets
161-
162154
# Enable pedantic lints - use this manually once in a while, but don't enable by default
163155
# pedantic = { level = "warn", priority = -1 }
164156

165-
# These were manually fixed already, and should be enforced
157+
# We are okay with the current state of these lints
166158
explicit_iter_loop = "warn"
159+
identity_op = "allow" # some expressions like `0 | x` are clearer for bit ops
167160
manual_assert = "warn"
168161
map_unwrap_or = "warn"
162+
missing_safety_doc = "allow" # safety? in libc? seriously?
163+
non_minimal_cfg = "allow" # for some reason cfg_if! sometimes trigger this
169164
ptr_as_ptr = "warn"
170165
unnecessary_semicolon = "warn"
171166

172-
# FIXME(clippy): these should eventually be fixed, or listed as OK
173-
cast_possible_truncation = "allow"
174-
cast_possible_wrap = "allow"
175-
cast_sign_loss = "allow"
167+
# FIXME(clippy): these should be fixed if possible
176168
expl_impl_clone_on_copy = "allow"
177-
must_use_candidate = "allow"
178-
pub_underscore_fields = "allow"
179-
struct_field_names = "allow"
180169
uninlined_format_args = "allow"
181-
unreadable_literal = "allow"
170+
unnecessary_cast = "allow" # some casts like `as usize` are only needed for some targets
182171
used_underscore_binding = "allow"
183-
used_underscore_items = "allow"
184-
verbose_bit_mask = "allow"

src/unix/solarish/compat.rs

Lines changed: 16 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
// Common functions that are unfortunately missing on illumos and
22
// Solaris, but often needed by other crates.
33
use core::cmp::min;
4-
#[cfg(target_os = "illumos")]
5-
use core::cmp::{Ord, Ordering};
64

75
use crate::unix::solarish::*;
86
use crate::{c_char, c_int, size_t};
@@ -90,18 +88,16 @@ pub unsafe fn openpty(
9088

9189
// Check if the STREAMS modules are already pushed:
9290
let setup = crate::ioctl(fds, I_FIND, LDTERM.as_ptr());
93-
match setup.cmp(&0) {
94-
Ordering::Less => return bail(fdm, fds),
95-
Ordering::Equal => {
96-
// The line discipline is not present, so push the appropriate STREAMS
97-
// modules for the subordinate device:
98-
if crate::ioctl(fds, I_PUSH, PTEM.as_ptr()) < 0
99-
|| crate::ioctl(fds, I_PUSH, LDTERM.as_ptr()) < 0
100-
{
101-
return bail(fdm, fds);
102-
}
91+
if setup < 0 {
92+
return bail(fdm, fds);
93+
} else if setup == 0 {
94+
// The line discipline is not present, so push the appropriate STREAMS
95+
// modules for the subordinate device:
96+
if crate::ioctl(fds, I_PUSH, PTEM.as_ptr()) < 0
97+
|| crate::ioctl(fds, I_PUSH, LDTERM.as_ptr()) < 0
98+
{
99+
return bail(fdm, fds);
103100
}
104-
Ordering::Greater => {}
105101
}
106102

107103
// If provided, set the terminal parameters:
@@ -142,17 +138,13 @@ pub unsafe fn forkpty(
142138
}
143139

144140
let pid = crate::fork();
145-
match pid.cmp(&0) {
146-
Ordering::Less => {
147-
return bail(*amain, fds);
148-
}
149-
Ordering::Greater => {
150-
// In the parent process, we close the subordinate device and return the
151-
// process ID of the new child:
152-
crate::close(fds);
153-
return pid;
154-
}
155-
Ordering::Equal => {}
141+
if pid < 0 {
142+
return bail(*amain, fds);
143+
} else if pid > 0 {
144+
// In the parent process, we close the subordinate device and return the
145+
// process ID of the new child:
146+
crate::close(fds);
147+
return pid;
156148
}
157149

158150
// The rest of this function executes in the child process.

0 commit comments

Comments
 (0)