Skip to content
This repository has been archived by the owner on Mar 25, 2024. It is now read-only.

Commit

Permalink
Clean up duplicated casting to size_t
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Dec 14, 2023
1 parent 902f100 commit e5f4bbd
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -374,7 +374,7 @@ unsafe fn yaml_string_write_handler(
size,
);
let fresh153 = addr_of_mut!((*(*emitter).output.string.size_written));
*fresh153 = (*fresh153 as libc::c_ulong).wrapping_add(size) as size_t as size_t;
*fresh153 = (*fresh153 as libc::c_ulong).wrapping_add(size) as size_t;
1
}

Expand Down
8 changes: 4 additions & 4 deletions src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1046,7 +1046,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
match (*event).type_ {
YAML_ALIAS_EVENT => {
length = (length as libc::c_ulong).wrapping_add((*emitter).anchor_data.anchor_length)
as size_t as size_t;
as size_t;
}
YAML_SCALAR_EVENT => {
if (*emitter).scalar_data.multiline {
Expand All @@ -1059,7 +1059,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
.wrapping_add((*emitter).tag_data.handle_length)
.wrapping_add((*emitter).tag_data.suffix_length)
.wrapping_add((*emitter).scalar_data.length),
) as size_t as size_t;
) as size_t;
}
YAML_SEQUENCE_START_EVENT => {
if !yaml_emitter_check_empty_sequence(emitter) {
Expand All @@ -1071,7 +1071,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
.anchor_length
.wrapping_add((*emitter).tag_data.handle_length)
.wrapping_add((*emitter).tag_data.suffix_length),
) as size_t as size_t;
) as size_t;
}
YAML_MAPPING_START_EVENT => {
if !yaml_emitter_check_empty_mapping(emitter) {
Expand All @@ -1083,7 +1083,7 @@ unsafe fn yaml_emitter_check_simple_key(emitter: *mut yaml_emitter_t) -> bool {
.anchor_length
.wrapping_add((*emitter).tag_data.handle_length)
.wrapping_add((*emitter).tag_data.suffix_length),
) as size_t as size_t;
) as size_t;
}
_ => return false,
}
Expand Down
9 changes: 4 additions & 5 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ unsafe fn yaml_parser_determine_encoding(parser: *mut yaml_parser_t) -> Success
let fresh1 = addr_of_mut!((*parser).raw_buffer.pointer);
*fresh1 = (*fresh1).wrapping_offset(2_isize);
let fresh2 = addr_of_mut!((*parser).offset);
*fresh2 = (*fresh2 as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t;
*fresh2 = (*fresh2 as libc::c_ulong).wrapping_add(2_u64) as size_t;
} else if (*parser)
.raw_buffer
.last
Expand All @@ -68,7 +68,7 @@ unsafe fn yaml_parser_determine_encoding(parser: *mut yaml_parser_t) -> Success
let fresh3 = addr_of_mut!((*parser).raw_buffer.pointer);
*fresh3 = (*fresh3).wrapping_offset(2_isize);
let fresh4 = addr_of_mut!((*parser).offset);
*fresh4 = (*fresh4 as libc::c_ulong).wrapping_add(2_u64) as size_t as size_t;
*fresh4 = (*fresh4 as libc::c_ulong).wrapping_add(2_u64) as size_t;
} else if (*parser)
.raw_buffer
.last
Expand All @@ -84,7 +84,7 @@ unsafe fn yaml_parser_determine_encoding(parser: *mut yaml_parser_t) -> Success
let fresh5 = addr_of_mut!((*parser).raw_buffer.pointer);
*fresh5 = (*fresh5).wrapping_offset(3_isize);
let fresh6 = addr_of_mut!((*parser).offset);
*fresh6 = (*fresh6 as libc::c_ulong).wrapping_add(3_u64) as size_t as size_t;
*fresh6 = (*fresh6 as libc::c_ulong).wrapping_add(3_u64) as size_t;
} else {
(*parser).encoding = YAML_UTF8_ENCODING;
}
Expand Down Expand Up @@ -397,8 +397,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
let fresh14 = addr_of_mut!((*parser).raw_buffer.pointer);
*fresh14 = (*fresh14).wrapping_offset(width as isize);
let fresh15 = addr_of_mut!((*parser).offset);
*fresh15 = (*fresh15 as libc::c_ulong).wrapping_add(width as libc::c_ulong) as size_t
as size_t;
*fresh15 = (*fresh15 as libc::c_ulong).wrapping_add(width as libc::c_ulong) as size_t;
if value <= 0x7F {
let fresh16 = addr_of_mut!((*parser).buffer.last);
let fresh17 = *fresh16;
Expand Down

0 comments on commit e5f4bbd

Please sign in to comment.