Delete cast to long followed by size_t

We are using 64 bits for both size_t and long.
This commit is contained in:
David Tolnay 2023-12-14 10:25:48 -08:00
parent e5f4bbd0f0
commit 97a4332d8d
No known key found for this signature in database
GPG key ID: F9BA143B95FF6D82
5 changed files with 13 additions and 19 deletions

View file

@ -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,

View file

@ -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
}
@ -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,
@ -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
}

View file

@ -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
{
@ -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,
@ -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;

View file

@ -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),
@ -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
@ -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 {
@ -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;

View file

@ -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);
@ -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);