From 97a4332d8d5a47478e659cb9b872ed6613eee8a9 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 14 Dec 2023 10:25:48 -0800 Subject: [PATCH] Delete cast to long followed by size_t We are using 64 bits for both size_t and long. --- src/api.rs | 4 ++-- src/emitter.rs | 8 +++----- src/reader.rs | 7 +++---- src/scanner.rs | 9 +++------ src/writer.rs | 4 ++-- 5 files changed, 13 insertions(+), 19 deletions(-) diff --git a/src/api.rs b/src/api.rs index 8231968..531b6b9 100644 --- a/src/api.rs +++ b/src/api.rs @@ -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, diff --git a/src/emitter.rs b/src/emitter.rs index c749ce9..27b9b26 100644 --- a/src/emitter.rs +++ b/src/emitter.rs @@ -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 } diff --git a/src/reader.rs b/src/reader.rs index 7348292..3877f60 100644 --- a/src/reader.rs +++ b/src/reader.rs @@ -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; diff --git a/src/scanner.rs b/src/scanner.rs index 175719c..e99f83e 100644 --- a/src/scanner.rs +++ b/src/scanner.rs @@ -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; diff --git a/src/writer.rs b/src/writer.rs index 11405bc..4a62f9e 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -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);