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

Commit

Permalink
Delete cast to long followed by size_t
Browse files Browse the repository at this point in the history
We are using 64 bits for both size_t and long.
  • Loading branch information
dtolnay committed Dec 14, 2023
1 parent e5f4bbd commit 97a4332
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ unsafe fn yaml_string_read_handler(
.input
.string
.end
.c_offset_from((*parser).input.string.current) as libc::c_long as size_t
.c_offset_from((*parser).input.string.current) as size_t
{
size = (*parser)
.input
.string
.end
.c_offset_from((*parser).input.string.current) as libc::c_long as size_t;
.c_offset_from((*parser).input.string.current) as size_t;
}
memcpy(
buffer as *mut libc::c_void,
Expand Down
8 changes: 3 additions & 5 deletions src/emitter.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1379,8 +1379,7 @@ unsafe fn yaml_emitter_analyze_anchor(
}
let fresh47 = addr_of_mut!((*emitter).anchor_data.anchor);
*fresh47 = string.start;
(*emitter).anchor_data.anchor_length =
string.end.c_offset_from(string.start) as libc::c_long as size_t;
(*emitter).anchor_data.anchor_length = string.end.c_offset_from(string.start) as size_t;
(*emitter).anchor_data.alias = alias;
OK
}
Expand All @@ -1398,7 +1397,7 @@ unsafe fn yaml_emitter_analyze_tag(emitter: *mut yaml_emitter_t, tag: *mut yaml_
tag_directive = (*emitter).tag_directives.start;
while tag_directive != (*emitter).tag_directives.top {
let prefix_length: size_t = strlen((*tag_directive).prefix as *mut libc::c_char);
if prefix_length < string.end.c_offset_from(string.start) as libc::c_long as size_t
if prefix_length < string.end.c_offset_from(string.start) as size_t
&& strncmp(
(*tag_directive).prefix as *mut libc::c_char,
string.start as *mut libc::c_char,
Expand All @@ -1420,8 +1419,7 @@ unsafe fn yaml_emitter_analyze_tag(emitter: *mut yaml_emitter_t, tag: *mut yaml_
}
let fresh50 = addr_of_mut!((*emitter).tag_data.suffix);
*fresh50 = string.start;
(*emitter).tag_data.suffix_length =
string.end.c_offset_from(string.start) as libc::c_long as size_t;
(*emitter).tag_data.suffix_length = string.end.c_offset_from(string.start) as size_t;
OK
}

Expand Down
7 changes: 3 additions & 4 deletions src/reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ unsafe fn yaml_parser_update_raw_buffer(parser: *mut yaml_parser_t) -> Success {
(*parser)
.raw_buffer
.end
.c_offset_from((*parser).raw_buffer.last) as libc::c_long as size_t,
.c_offset_from((*parser).raw_buffer.last) as size_t,
addr_of_mut!(size_read),
) == 0
{
Expand Down Expand Up @@ -171,8 +171,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
let size: size_t = (*parser)
.buffer
.last
.c_offset_from((*parser).buffer.pointer) as libc::c_long
as size_t;
.c_offset_from((*parser).buffer.pointer) as size_t;
memmove(
(*parser).buffer.start as *mut libc::c_void,
(*parser).buffer.pointer as *const libc::c_void,
Expand Down Expand Up @@ -208,7 +207,7 @@ pub(crate) unsafe fn yaml_parser_update_buffer(
.raw_buffer
.last
.c_offset_from((*parser).raw_buffer.pointer)
as libc::c_long as size_t;
as size_t;
match (*parser).encoding {
YAML_UTF8_ENCODING => {
octet = *(*parser).raw_buffer.pointer;
Expand Down
9 changes: 3 additions & 6 deletions src/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1592,7 +1592,7 @@ unsafe fn yaml_parser_scan_tag_uri(
return FAIL;
}
_ => {
if string.end.c_offset_from(string.start) as libc::c_long as size_t <= length {
if string.end.c_offset_from(string.start) as size_t <= length {
yaml_string_extend(
addr_of_mut!(string.start),
addr_of_mut!(string.pointer),
Expand Down Expand Up @@ -1992,7 +1992,6 @@ unsafe fn yaml_parser_scan_block_scalar(
*fresh479 = string.start;
(*token).data.scalar.length =
string.pointer.c_offset_from(string.start)
as libc::c_long
as size_t;
(*token).data.scalar.style = if literal {
YAML_LITERAL_SCALAR_STYLE
Expand Down Expand Up @@ -2462,8 +2461,7 @@ unsafe fn yaml_parser_scan_flow_scalar(
(*token).end_mark = end_mark;
let fresh716 = addr_of_mut!((*token).data.scalar.value);
*fresh716 = string.start;
(*token).data.scalar.length =
string.pointer.c_offset_from(string.start) as libc::c_long as size_t;
(*token).data.scalar.length = string.pointer.c_offset_from(string.start) as size_t;
(*token).data.scalar.style = if single {
YAML_SINGLE_QUOTED_SCALAR_STYLE
} else {
Expand Down Expand Up @@ -2644,8 +2642,7 @@ unsafe fn yaml_parser_scan_plain_scalar(
(*token).end_mark = end_mark;
let fresh842 = addr_of_mut!((*token).data.scalar.value);
*fresh842 = string.start;
(*token).data.scalar.length =
string.pointer.c_offset_from(string.start) as libc::c_long as size_t;
(*token).data.scalar.length = string.pointer.c_offset_from(string.start) as size_t;
(*token).data.scalar.style = YAML_PLAIN_SCALAR_STYLE;
if leading_blanks {
(*parser).simple_key_allowed = true;
Expand Down
4 changes: 2 additions & 2 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> Success {
(*emitter)
.buffer
.last
.c_offset_from((*emitter).buffer.start) as libc::c_long as size_t,
.c_offset_from((*emitter).buffer.start) as size_t,
) != 0
{
let fresh3 = addr_of_mut!((*emitter).buffer.last);
Expand Down Expand Up @@ -127,7 +127,7 @@ pub unsafe fn yaml_emitter_flush(emitter: *mut yaml_emitter_t) -> Success {
(*emitter)
.raw_buffer
.last
.c_offset_from((*emitter).raw_buffer.start) as libc::c_long as size_t,
.c_offset_from((*emitter).raw_buffer.start) as size_t,
) != 0
{
let fresh8 = addr_of_mut!((*emitter).buffer.last);
Expand Down

0 comments on commit 97a4332

Please sign in to comment.