Skip to content

Commit d3e2820

Browse files
committed
Use meaningful TRUE constant
1 parent 9290e56 commit d3e2820

File tree

6 files changed

+22
-14
lines changed

6 files changed

+22
-14
lines changed

src/backtrace/dbghelp32.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
158158
Some(get_module_base),
159159
None,
160160
0,
161-
) == 1
161+
) == TRUE
162162
{
163163
frame.inner.base_address = get_module_base(process_handle, frame.ip() as _) as _;
164164

@@ -190,7 +190,7 @@ pub unsafe fn trace(cb: &mut dyn FnMut(&super::Frame) -> bool) {
190190
Some(function_table_access),
191191
Some(get_module_base),
192192
None,
193-
) == 1
193+
) == TRUE
194194
{
195195
frame.inner.base_address = get_module_base(process_handle, frame.ip() as _) as _;
196196

src/dbghelp.rs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,13 @@
2626
use alloc::vec::Vec;
2727

2828
use windows_sys::{
29-
core::*, Win32::Foundation::*, Win32::System::Diagnostics::Debug::*,
29+
core::*,
30+
Win32::Foundation::*, Win32::System::Diagnostics::Debug::*,
3031
Win32::System::LibraryLoader::*, Win32::System::Threading::*,
3132
Win32::System::WindowsProgramming::*, Win32::Globalization::*,
3233
};
3334

35+
use super::windows::*;
3436
use core::ffi::c_void;
3537
use core::mem;
3638
use core::ptr;
@@ -355,7 +357,7 @@ fn set_optional_options() -> Option<()> {
355357
// the time, but now that it's using this crate it means that someone will
356358
// get to initialization first and the other will pick up that
357359
// initialization.
358-
DBGHELP.SymInitializeW()?(GetCurrentProcess(), ptr::null_mut(), 1);
360+
DBGHELP.SymInitializeW()?(GetCurrentProcess(), ptr::null_mut(), TRUE);
359361

360362
// The default search path for dbghelp will only look in the current working
361363
// directory and (possibly) `_NT_SYMBOL_PATH` and `_NT_ALT_SYMBOL_PATH`.
@@ -373,7 +375,7 @@ fn set_optional_options() -> Option<()> {
373375
GetCurrentProcess(),
374376
search_path_buf.as_mut_ptr(),
375377
search_path_buf.len() as _,
376-
) == 1
378+
) == TRUE
377379
{
378380
// Trim the buffer to the actual length of the string.
379381
let len = lstrlenW(search_path_buf.as_mut_ptr());
@@ -459,7 +461,7 @@ extern "system" fn enum_loaded_modules_callback(
459461

460462
if len == 0 {
461463
// This should not happen, but if it does, we can just ignore it.
462-
return 1;
464+
return TRUE;
463465
}
464466

465467
let module_name = unsafe { slice::from_raw_parts(module_name, len) };
@@ -472,13 +474,13 @@ extern "system" fn enum_loaded_modules_callback(
472474
else {
473475
// `module_name` being an absolute path, it should always contain at least one
474476
// path separator. If not, there is nothing we can do.
475-
return 1;
477+
return TRUE;
476478
};
477479

478480
let search_path = unsafe { &mut *(user_context as *mut SearchPath) };
479481
search_path.add(&module_name[..end_of_directory]);
480482

481-
1
483+
TRUE
482484
}
483485

484486
impl Drop for Init {

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,3 +248,5 @@ mod lock {
248248
not(target_vendor = "uwp")
249249
))]
250250
mod dbghelp;
251+
#[cfg(windows)]
252+
mod windows;

src/symbolize/dbghelp.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ use windows_sys::{
2222
Win32::Globalization::*,
2323
};
2424

25-
use super::super::dbghelp;
25+
use super::super::{dbghelp, windows::*};
2626
use super::{BytesOrWideString, ResolveWhat, SymbolName};
2727
use core::ffi::c_void;
2828
use core::marker;
@@ -181,7 +181,7 @@ unsafe fn resolve_with_inline(
181181
addr,
182182
&mut inline_context,
183183
&mut 0,
184-
) != 1)
184+
) != TRUE)
185185
|| inlined_frame_count == 0
186186
{
187187
inlined_frame_count = 0;
@@ -219,7 +219,7 @@ unsafe fn do_resolve(
219219
// due to struct alignment.
220220
info.SizeOfStruct = 88;
221221

222-
if sym_from_addr(info) != 1 {
222+
if sym_from_addr(info) != TRUE {
223223
return;
224224
}
225225

@@ -257,7 +257,7 @@ unsafe fn do_resolve(
257257

258258
let mut filename = None;
259259
let mut lineno = None;
260-
if get_line_from_addr(&mut line) == 1 {
260+
if get_line_from_addr(&mut line) == TRUE {
261261
lineno = Some(line.LineNumber);
262262

263263
let base = line.FileName;

src/symbolize/gimli/libs_windows.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,13 @@ unsafe fn add_loaded_images(ret: &mut Vec<Library>) {
2424

2525
let mut me = MaybeUninit::<MODULEENTRY32W>::zeroed().assume_init();
2626
me.dwSize = mem::size_of_val(&me) as u32;
27-
if Module32FirstW(snap, &mut me) == 1 {
27+
if Module32FirstW(snap, &mut me) == TRUE {
2828
loop {
2929
if let Some(lib) = load_library(&me) {
3030
ret.push(lib);
3131
}
3232

33-
if Module32NextW(snap, &mut me) != 1 {
33+
if Module32NextW(snap, &mut me) != TRUE {
3434
break;
3535
}
3636
}

src/windows.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
2+
use windows_sys::Win32::Foundation::*;
3+
4+
pub const TRUE: BOOL = 1;

0 commit comments

Comments
 (0)