diff --git a/.github/workflows/internal-testsuite.yml b/.github/workflows/internal-testsuite.yml index 09324b9e00..5fc37f6597 100644 --- a/.github/workflows/internal-testsuite.yml +++ b/.github/workflows/internal-testsuite.yml @@ -114,11 +114,17 @@ jobs: export LLVM_CONFIG_PATH=/usr/bin/llvm-config-${{ matrix.clang-version }} cargo build --release + - name: Build tools + run: | + # `cd tools` to pick up `tools/rust-toolchain.toml` (stable, for `edition = "2024"`) + (cd tools && cargo build --release --manifest-path split_rust/Cargo.toml) + (cd tools && cargo build --release --manifest-path merge_rust/Cargo.toml) + # TODO(pl): figure out why compile_commands.json may cause json-c to fail - name: Run c2rust testsuite run: | find tests/integration -type f -name compile_commands.json -delete - export PATH=$PWD/target/release:$HOME/.local/bin:$PATH + export PATH=$PWD/target/release:$PWD/c2rust-postprocess:$HOME/.local/bin:$PATH echo "PATH=$PATH" export C2RUST_DIR=$PWD # Needs to be run from `tests/integration/` (or further inside) diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/metadata.toml similarity index 93% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/metadata.toml index 3c4cbc3309..93cc6b1c3c 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/metadata.toml @@ -5,10 +5,10 @@ response = """#[no_mangle] pub unsafe extern "C" fn _json_c_set_last_err( mut err_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) { let mut ap: ::core::ffi::VaListImpl; - ap = args.clone(); + ap = c2rust_args.clone(); // Ignore (attempted) overruns from snprintf vsnprintf( &raw mut _last_err as *mut ::core::ffi::c_char, @@ -42,10 +42,10 @@ Rust function: pub unsafe extern "C" fn _json_c_set_last_err( mut err_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) { let mut ap: ::core::ffi::VaListImpl; - ap = args.clone(); + ap = c2rust_args.clone(); vsnprintf( &raw mut _last_err as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 256]>() as size_t, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/response.txt similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/response.txt index 544a4fde16..2975671893 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/9adf00d95ad0a6f053bb53b6cd6f44351e53f231893f4c9666ed52cf00d9921a/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_set_last_err/fb382342868472bec62abc2d1622940d0cc38260f04f8d809e377f88b880d282/response.txt @@ -2,10 +2,10 @@ pub unsafe extern "C" fn _json_c_set_last_err( mut err_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) { let mut ap: ::core::ffi::VaListImpl; - ap = args.clone(); + ap = c2rust_args.clone(); // Ignore (attempted) overruns from snprintf vsnprintf( &raw mut _last_err as *mut ::core::ffi::c_char, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/metadata.toml similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/metadata.toml index 990be31e1e..b4635814df 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/metadata.toml @@ -20,14 +20,14 @@ unsafe extern "C" fn _json_c_visit( ); match userret { crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => {} - crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - | crate::src::json_visit::JSON_C_VISIT_RETURN_POP - | crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - | crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, + crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP | + crate::src::json_visit::JSON_C_VISIT_RETURN_POP | + crate::src::json_visit::JSON_C_VISIT_RETURN_STOP | + crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -42,15 +42,15 @@ unsafe extern "C" fn _json_c_visit( 4 => { let mut key: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut child: *mut json_object = ::core::ptr::null_mut::(); - let mut entrykey: *mut lh_entry = - (*(json_object_get_object(jso) as *mut lh_table)).head; + let mut entrykey: *mut lh_entry = (*(json_object_get_object(jso) as + *mut lh_table)).head; let mut entry_nextkey: *mut lh_entry = ::core::ptr::null_mut::(); while !({ if !entrykey.is_null() { key = (*entrykey).k as uintptr_t as *mut ::core::ffi::c_void as *mut ::core::ffi::c_char; - child = (*entrykey).v as uintptr_t as *mut ::core::ffi::c_void - as *mut json_object; + child = + (*entrykey).v as uintptr_t as *mut ::core::ffi::c_void as *mut json_object; entry_nextkey = (*entrykey).next; } entrykey @@ -68,17 +68,13 @@ unsafe extern "C" fn _json_c_visit( if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_POP { break; } - if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR - { + if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR { return userret; } - if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE - && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - { + if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -105,17 +101,13 @@ unsafe extern "C" fn _json_c_visit( if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_POP { break; } - if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR - { + if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR { return userret; } - if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE - && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - { + if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -127,7 +119,7 @@ unsafe extern "C" fn _json_c_visit( _ => { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, json_object_get_type(jso) as ::core::ffi::c_uint, ); @@ -148,26 +140,26 @@ unsafe extern "C" fn _json_c_visit( userarg, ); match userret { - crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - | crate::src::json_visit::JSON_C_VISIT_RETURN_POP - | crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => { - // These are not really sensible during JSON_C_VISIT_SECOND, + crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP | + crate::src::json_visit::JSON_C_VISIT_RETURN_POP | + crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => { + // These are not really sensible during JSON_C_VISIT_SECOND, // but map them to JSON_C_VISIT_CONTINUE anyway. // FALLTHROUGH return crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE; } - crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - | crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, + crate::src::json_visit::JSON_C_VISIT_RETURN_STOP | + crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); return crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR; } - }; + } // NOTREACHED } ```""" @@ -307,7 +299,7 @@ unsafe extern "C" fn _json_c_visit( _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -351,7 +343,7 @@ unsafe extern "C" fn _json_c_visit( if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -384,7 +376,7 @@ unsafe extern "C" fn _json_c_visit( if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -396,7 +388,7 @@ unsafe extern "C" fn _json_c_visit( _ => { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\\n\\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, json_object_get_type(jso) as ::core::ffi::c_uint, ); @@ -422,7 +414,7 @@ unsafe extern "C" fn _json_c_visit( _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\\n\\0".as_ptr() as *const ::core::ffi::c_char, userret, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/response.txt similarity index 78% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/response.txt index 737f30bb2a..c4565f9d1a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/74372ced09d061616fb9dfc91f6f63ab6388eb2f6a682fee1630f82ee6936a07/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_c_visit/f533bfb5ea7ecc504f19c2942031e04d7104fb910f97bb59a927cd2d570b4dab/response.txt @@ -17,14 +17,14 @@ unsafe extern "C" fn _json_c_visit( ); match userret { crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => {} - crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - | crate::src::json_visit::JSON_C_VISIT_RETURN_POP - | crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - | crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, + crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP | + crate::src::json_visit::JSON_C_VISIT_RETURN_POP | + crate::src::json_visit::JSON_C_VISIT_RETURN_STOP | + crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\n\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\n\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -39,15 +39,15 @@ unsafe extern "C" fn _json_c_visit( 4 => { let mut key: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut child: *mut json_object = ::core::ptr::null_mut::(); - let mut entrykey: *mut lh_entry = - (*(json_object_get_object(jso) as *mut lh_table)).head; + let mut entrykey: *mut lh_entry = (*(json_object_get_object(jso) as + *mut lh_table)).head; let mut entry_nextkey: *mut lh_entry = ::core::ptr::null_mut::(); while !({ if !entrykey.is_null() { key = (*entrykey).k as uintptr_t as *mut ::core::ffi::c_void as *mut ::core::ffi::c_char; - child = (*entrykey).v as uintptr_t as *mut ::core::ffi::c_void - as *mut json_object; + child = + (*entrykey).v as uintptr_t as *mut ::core::ffi::c_void as *mut json_object; entry_nextkey = (*entrykey).next; } entrykey @@ -65,17 +65,13 @@ unsafe extern "C" fn _json_c_visit( if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_POP { break; } - if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR - { + if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR { return userret; } - if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE - && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - { + if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\n\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\n\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -102,17 +98,13 @@ unsafe extern "C" fn _json_c_visit( if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_POP { break; } - if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR - { + if userret == crate::src::json_visit::JSON_C_VISIT_RETURN_STOP || userret == crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR { return userret; } - if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE - && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - { + if userret != crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE && userret != crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit returned %d\n\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit returned %d\n\0".as_ptr() as *const ::core::ffi::c_char, userret, ); @@ -124,7 +116,7 @@ unsafe extern "C" fn _json_c_visit( _ => { fprintf( stderr, - b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\n\0" as *const u8 + b"INTERNAL ERROR: _json_c_visit found object of unknown type: %d\n\0".as_ptr() as *const ::core::ffi::c_char, json_object_get_type(jso) as ::core::ffi::c_uint, ); @@ -145,26 +137,26 @@ unsafe extern "C" fn _json_c_visit( userarg, ); match userret { - crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP - | crate::src::json_visit::JSON_C_VISIT_RETURN_POP - | crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => { - // These are not really sensible during JSON_C_VISIT_SECOND, + crate::src::json_visit::JSON_C_VISIT_RETURN_SKIP | + crate::src::json_visit::JSON_C_VISIT_RETURN_POP | + crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE => { + // These are not really sensible during JSON_C_VISIT_SECOND, // but map them to JSON_C_VISIT_CONTINUE anyway. // FALLTHROUGH return crate::src::json_visit::JSON_C_VISIT_RETURN_CONTINUE; } - crate::src::json_visit::JSON_C_VISIT_RETURN_STOP - | crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, + crate::src::json_visit::JSON_C_VISIT_RETURN_STOP | + crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR => return userret, _ => { fprintf( stderr, - b"ERROR: invalid return value from json_c_visit userfunc: %d\n\0" as *const u8 + b"ERROR: invalid return value from json_c_visit userfunc: %d\n\0".as_ptr() as *const ::core::ffi::c_char, userret, ); return crate::src::json_visit::JSON_C_VISIT_RETURN_ERROR; } - }; + } // NOTREACHED } ``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/metadata.toml similarity index 92% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/metadata.toml index 8492281b2c..835f304ce5 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/metadata.toml @@ -15,11 +15,11 @@ unsafe extern "C" fn _json_object_to_fd( filename = if !filename.is_null() { filename } else { - b"(fd)\\0" as *const u8 as *const ::core::ffi::c_char + b"(fd)\\0".as_ptr() as *const ::core::ffi::c_char }; json_str = json_object_to_json_string_ext(obj, flags); if json_str.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } wsize = (strlen(json_str) & UINT_MAX as size_t) as ::core::ffi::c_uint; /* CAW: probably unnecessary, but the most 64bit safe */ wpos = 0 as ::core::ffi::c_uint; @@ -31,13 +31,14 @@ unsafe extern "C" fn _json_object_to_fd( ) as ::core::ffi::c_int; if ret < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error writing file %s: %s\\n\\0" as *const u8 + b"json_object_to_file: error writing file %s: %s\\n\\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } + /* because of the above check for ret < 0, we can safely cast and add */ wpos = wpos.wrapping_add(ret as ::core::ffi::c_uint); } @@ -97,11 +98,11 @@ unsafe extern "C" fn _json_object_to_fd( filename = if !filename.is_null() { filename } else { - b"(fd)\\0" as *const u8 as *const ::core::ffi::c_char + b"(fd)\\0".as_ptr() as *const ::core::ffi::c_char }; json_str = json_object_to_json_string_ext(obj, flags); if json_str.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } wsize = (strlen(json_str) & UINT_MAX as size_t) as ::core::ffi::c_uint; wpos = 0 as ::core::ffi::c_uint; @@ -113,12 +114,12 @@ unsafe extern "C" fn _json_object_to_fd( ) as ::core::ffi::c_int; if ret < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error writing file %s: %s\\n\\0" as *const u8 + b"json_object_to_file: error writing file %s: %s\\n\\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } wpos = wpos.wrapping_add(ret as ::core::ffi::c_uint); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/response.txt similarity index 89% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/response.txt index 4163f2b5af..739efa2f48 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/89aa8f3971f321ba3d023a079202addbf47d1407724098a6a858817fd0eede3c/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/_json_object_to_fd/1cb613e3112864651b08112f1c5c7f4e4dfe7e8adf7002431c851917878758cb/response.txt @@ -12,11 +12,11 @@ unsafe extern "C" fn _json_object_to_fd( filename = if !filename.is_null() { filename } else { - b"(fd)\0" as *const u8 as *const ::core::ffi::c_char + b"(fd)\0".as_ptr() as *const ::core::ffi::c_char }; json_str = json_object_to_json_string_ext(obj, flags); if json_str.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } wsize = (strlen(json_str) & UINT_MAX as size_t) as ::core::ffi::c_uint; /* CAW: probably unnecessary, but the most 64bit safe */ wpos = 0 as ::core::ffi::c_uint; @@ -28,13 +28,14 @@ unsafe extern "C" fn _json_object_to_fd( ) as ::core::ffi::c_int; if ret < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error writing file %s: %s\n\0" as *const u8 + b"json_object_to_file: error writing file %s: %s\n\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } + /* because of the above check for ret < 0, we can safely cast and add */ wpos = wpos.wrapping_add(ret as ::core::ffi::c_uint); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/metadata.toml similarity index 95% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/metadata.toml index a7973a9909..5129cd04cd 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/metadata.toml @@ -24,14 +24,14 @@ unsafe extern "C" fn array_list_expand_internal( > (!(0 as ::core::ffi::c_int as size_t)) .wrapping_div(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t) { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } t = realloc( (*arr).array as *mut ::core::ffi::c_void, new_size.wrapping_mul(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t), ); if t.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*arr).array = t as *mut *mut ::core::ffi::c_void; memset( @@ -101,14 +101,14 @@ unsafe extern "C" fn array_list_expand_internal( > (!(0 as ::core::ffi::c_int as size_t)) .wrapping_div(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t) { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } t = realloc( (*arr).array as *mut ::core::ffi::c_void, new_size.wrapping_mul(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t), ); if t.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*arr).array = t as *mut *mut ::core::ffi::c_void; memset( diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/response.txt similarity index 94% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/response.txt index ac9b389d03..5a7ff35a4a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/19cfb0e46106329dcaf89e1684e09003437a1b0f9831a6963416b8e2a8bd7e1a/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/array_list_expand_internal/c0c79ea7c671b8714d9009dccad6a576faa31c2ea75659c8df26780c5016fb2e/response.txt @@ -21,14 +21,14 @@ unsafe extern "C" fn array_list_expand_internal( > (!(0 as ::core::ffi::c_int as size_t)) .wrapping_div(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t) { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } t = realloc( (*arr).array as *mut ::core::ffi::c_void, new_size.wrapping_mul(::core::mem::size_of::<*mut ::core::ffi::c_void>() as size_t), ); if t.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*arr).array = t as *mut *mut ::core::ffi::c_void; memset( diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/metadata.toml similarity index 89% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/metadata.toml index 7d8231a0bf..8f9174269c 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/metadata.toml @@ -7,7 +7,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if fd < 0 as ::core::ffi::c_int { fprintf( stderr, - b"error opening %s: %s\\0" as *const u8 as *const ::core::ffi::c_char, + b"error opening %s: %s\\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); @@ -22,7 +22,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if nread as usize != ::core::mem::size_of::<::core::ffi::c_int>() as usize { fprintf( stderr, - b"error short read %s: %s\\0" as *const u8 as *const ::core::ffi::c_char, + b"error short read %s: %s\\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); @@ -71,7 +71,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if fd < 0 as ::core::ffi::c_int { fprintf( stderr, - b"error opening %s: %s\\0" as *const u8 as *const ::core::ffi::c_char, + b"error opening %s: %s\\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); @@ -86,7 +86,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if nread as usize != ::core::mem::size_of::<::core::ffi::c_int>() as usize { fprintf( stderr, - b"error short read %s: %s\\0" as *const u8 as *const ::core::ffi::c_char, + b"error short read %s: %s\\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/response.txt similarity index 83% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/response.txt index 3f6278f7ce..7919c62f91 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/654ec79873ddbc326edd81c2326c91604c0726d80117e2d18e8f48e3ae5a61f5/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/get_dev_random_seed/c8366b0e02e7156add496cb17b9b0278bdc89ec13ae300eba9ef81b6a2f21e6c/response.txt @@ -4,7 +4,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if fd < 0 as ::core::ffi::c_int { fprintf( stderr, - b"error opening %s: %s\0" as *const u8 as *const ::core::ffi::c_char, + b"error opening %s: %s\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); @@ -19,7 +19,7 @@ unsafe extern "C" fn get_dev_random_seed() -> ::core::ffi::c_int { if nread as usize != ::core::mem::size_of::<::core::ffi::c_int>() as usize { fprintf( stderr, - b"error short read %s: %s\0" as *const u8 as *const ::core::ffi::c_char, + b"error short read %s: %s\0".as_ptr() as *const ::core::ffi::c_char, dev_random_file, _json_c_strerror(*__errno_location()), ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/metadata.toml similarity index 96% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/metadata.toml index 4ec2b8ab79..b3cf7b741a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/metadata.toml @@ -36,12 +36,12 @@ pub unsafe extern "C" fn json_c_shallow_copy_default( } _ => { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } } if (*dst).is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (**dst)._to_json_string = (*src)._to_json_string; // _userdata and _user_delete are copied later @@ -138,12 +138,12 @@ pub unsafe extern "C" fn json_c_shallow_copy_default( } _ => { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } } if (*dst).is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (**dst)._to_json_string = (*src)._to_json_string; return 1 as ::core::ffi::c_int; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/response.txt similarity index 94% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/response.txt index 2040516feb..e4448189b3 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/932d42cc819c306fb465684b9cb71994e1ba9d8f715bd34cf9611e310466be19/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_c_shallow_copy_default/65c2afd3a6140b13a058515ae80748d504daef4f86910149db6448398e1abd68/response.txt @@ -33,12 +33,12 @@ pub unsafe extern "C" fn json_c_shallow_copy_default( } _ => { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } } if (*dst).is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (**dst)._to_json_string = (*src)._to_json_string; // _userdata and _user_delete are copied later diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/metadata.toml similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/metadata.toml index 9731783af6..d1141c7379 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/metadata.toml @@ -12,9 +12,9 @@ unsafe extern "C" fn json_escape_str( let mut start_offset: ::core::ffi::c_int = 0 as ::core::ffi::c_int; let mut c: ::core::ffi::c_uchar = 0; loop { - let fresh0 = len; + let c2rust_fresh0 = len; len = len - 1; - if !(fresh0 != 0) { + if !(c2rust_fresh0 != 0) { break; } c = *str.offset(pos as isize) as ::core::ffi::c_uchar; @@ -35,49 +35,49 @@ unsafe extern "C" fn json_escape_str( if c as ::core::ffi::c_int == '\\u{8}' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\b\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\b\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\n' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\n\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\r' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\r\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\r\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\t' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\t\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\t\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\u{c}' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\f\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\f\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '"' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\\\"\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\\\' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\\\\\\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\\\\\\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '/' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\/\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\/\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } @@ -98,7 +98,7 @@ unsafe extern "C" fn json_escape_str( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 7]>() as size_t, - b"\\\\u00%c%c\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\u00%c%c\\0".as_ptr() as *const ::core::ffi::c_char, *json_hex_chars .offset((c as ::core::ffi::c_int >> 4 as ::core::ffi::c_int) as isize) as ::core::ffi::c_int, @@ -231,9 +231,9 @@ unsafe extern "C" fn json_escape_str( let mut start_offset: ::core::ffi::c_int = 0 as ::core::ffi::c_int; let mut c: ::core::ffi::c_uchar = 0; loop { - let fresh0 = len; + let c2rust_fresh0 = len; len = len - 1; - if !(fresh0 != 0) { + if !(c2rust_fresh0 != 0) { break; } c = *str.offset(pos as isize) as ::core::ffi::c_uchar; @@ -256,56 +256,56 @@ unsafe extern "C" fn json_escape_str( printbuf_memappend( pb as *mut printbuf, - b"\\\\b\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\b\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\n' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\n\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\r' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\r\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\r\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\t' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\t\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\t\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\u{c}' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\f\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\f\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '"' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\\\"\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\\\' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\\\\\\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\\\\\\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '/' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\/\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\/\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } @@ -327,7 +327,7 @@ unsafe extern "C" fn json_escape_str( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 7]>() as size_t, - b"\\\\u00%c%c\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\u00%c%c\\0".as_ptr() as *const ::core::ffi::c_char, *json_hex_chars .offset((c as ::core::ffi::c_int >> 4 as ::core::ffi::c_int) as isize) as ::core::ffi::c_int, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/response.txt similarity index 88% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/response.txt index c296f3ebf1..b8e899d6dc 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/0a96667bfec58caa92dc7c5db32b373c7d643e9247bdf5f4bad78437c662b4a1/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_escape_str/fc72454d5c86772f9705e8acff2f2cd47f3fad488e7e92d9aac1e02c53d077f7/response.txt @@ -9,9 +9,9 @@ unsafe extern "C" fn json_escape_str( let mut start_offset: ::core::ffi::c_int = 0 as ::core::ffi::c_int; let mut c: ::core::ffi::c_uchar = 0; loop { - let fresh0 = len; + let c2rust_fresh0 = len; len = len - 1; - if !(fresh0 != 0) { + if !(c2rust_fresh0 != 0) { break; } c = *str.offset(pos as isize) as ::core::ffi::c_uchar; @@ -32,49 +32,49 @@ unsafe extern "C" fn json_escape_str( if c as ::core::ffi::c_int == '\u{8}' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\b\0" as *const u8 as *const ::core::ffi::c_char, + b"\\b\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\n' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\r' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\r\0" as *const u8 as *const ::core::ffi::c_char, + b"\\r\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\t' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\t\0" as *const u8 as *const ::core::ffi::c_char, + b"\\t\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\u{c}' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\f\0" as *const u8 as *const ::core::ffi::c_char, + b"\\f\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '"' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\"\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\"\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '\\' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\\\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\\\\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } else if c as ::core::ffi::c_int == '/' as i32 { printbuf_memappend( pb as *mut printbuf, - b"\\/\0" as *const u8 as *const ::core::ffi::c_char, + b"\\/\0".as_ptr() as *const ::core::ffi::c_char, 2 as ::core::ffi::c_int, ); } @@ -95,7 +95,7 @@ unsafe extern "C" fn json_escape_str( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 7]>() as size_t, - b"\\u00%c%c\0" as *const u8 as *const ::core::ffi::c_char, + b"\\u00%c%c\0".as_ptr() as *const ::core::ffi::c_char, *json_hex_chars .offset((c as ::core::ffi::c_int >> 4 as ::core::ffi::c_int) as isize) as ::core::ffi::c_int, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/metadata.toml similarity index 92% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/metadata.toml index bcf39b1e3b..11455ea206 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/metadata.toml @@ -18,12 +18,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso1) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso1) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1277 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -33,12 +33,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso2) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso2) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1278 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -94,7 +94,8 @@ unsafe extern "C" fn json_object_all_values_equal( iter.entry = (*iter.entry).next as *mut lh_entry; } return 1 as ::core::ffi::c_int; -}```""" +} +```""" [[messages]] role = "user" @@ -150,12 +151,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso1) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso1) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1277 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -165,12 +166,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso2) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso2) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1278 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/response.txt similarity index 91% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/response.txt index 55fb4bf2a5..a263a52d3c 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/85cd588b8c400a2042f7ff7a1c1381ed1281857e85408a4fb18d75a29773a71f/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_all_values_equal/5da51211c6ef4150f9217098c3617755c011e99bdf87bba2a67335daf7db062e/response.txt @@ -15,12 +15,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso1) == json_type_object\0" as *const u8 + b"json_object_get_type(jso1) == json_type_object\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 1277 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -30,12 +30,12 @@ unsafe extern "C" fn json_object_all_values_equal( { } else { __assert_fail( - b"json_object_get_type(jso2) == json_type_object\0" as *const u8 + b"json_object_get_type(jso2) == json_type_object\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 1278 as ::core::ffi::c_uint, b"int json_object_all_values_equal(struct json_object *, struct json_object *)\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -91,4 +91,5 @@ unsafe extern "C" fn json_object_all_values_equal( iter.entry = (*iter.entry).next as *mut lh_entry; } return 1 as ::core::ffi::c_int; -}``` \ No newline at end of file +} +``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/metadata.toml similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/metadata.toml index 74c7edebb1..62de6bb7b5 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/metadata.toml @@ -13,7 +13,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"[\\0" as *const u8 as *const ::core::ffi::c_char, + b"[\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -21,7 +21,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -33,7 +33,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b",\\0" as *const u8 as *const ::core::ffi::c_char, + b",\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -41,7 +41,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -52,7 +52,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b" \\0" as *const u8 as *const ::core::ffi::c_char, + b" \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -63,7 +63,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"null\\0" as *const u8 as *const ::core::ffi::c_char, + b"null\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -74,7 +74,7 @@ unsafe extern "C" fn json_object_array_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } @@ -83,7 +83,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -94,7 +94,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b" ]\\0" as *const u8 as *const ::core::ffi::c_char, + b" ]\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -102,7 +102,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"]\\0" as *const u8 as *const ::core::ffi::c_char, + b"]\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -175,7 +175,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"[\\0" as *const u8 as *const ::core::ffi::c_char, + b"[\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -183,7 +183,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -195,7 +195,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b",\\0" as *const u8 as *const ::core::ffi::c_char, + b",\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -203,7 +203,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -214,7 +214,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b" \\0" as *const u8 as *const ::core::ffi::c_char, + b" \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -225,7 +225,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"null\\0" as *const u8 as *const ::core::ffi::c_char, + b"null\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -236,7 +236,7 @@ unsafe extern "C" fn json_object_array_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } @@ -245,7 +245,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -256,7 +256,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b" ]\\0" as *const u8 as *const ::core::ffi::c_char, + b" ]\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -264,7 +264,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"]\\0" as *const u8 as *const ::core::ffi::c_char, + b"]\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/response.txt similarity index 85% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/response.txt index c5ef6212bc..545c7f1b9c 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/1f85b0363eb0fcba123430f9b2bab1f79339c7bc0f69bdb7cb50d77a2fe94372/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_array_to_json_string/84e25fe9f77097ec8bf466ac06895c5f567d6a10c779df1c8567bfc070b07687/response.txt @@ -10,7 +10,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"[\0" as *const u8 as *const ::core::ffi::c_char, + b"[\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -18,7 +18,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -30,7 +30,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b",\0" as *const u8 as *const ::core::ffi::c_char, + b",\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -38,7 +38,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -49,7 +49,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b" \0" as *const u8 as *const ::core::ffi::c_char, + b" \0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -60,7 +60,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"null\0" as *const u8 as *const ::core::ffi::c_char, + b"null\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -71,7 +71,7 @@ unsafe extern "C" fn json_object_array_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } @@ -80,7 +80,7 @@ unsafe extern "C" fn json_object_array_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -91,7 +91,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b" ]\0" as *const u8 as *const ::core::ffi::c_char, + b" ]\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -99,7 +99,7 @@ unsafe extern "C" fn json_object_array_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"]\0" as *const u8 as *const ::core::ffi::c_char, + b"]\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/metadata.toml similarity index 89% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/metadata.toml index 4c764ac1a5..c60016eac5 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/metadata.toml @@ -11,14 +11,14 @@ unsafe extern "C" fn json_object_boolean_to_json_string( if (*jso).o.c_boolean != 0 { return printbuf_memappend( pb as *mut printbuf, - b"true\\0" as *const u8 as *const ::core::ffi::c_char, + b"true\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } return printbuf_memappend( pb as *mut printbuf, - b"false\\0" as *const u8 as *const ::core::ffi::c_char, + b"false\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 6]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -57,7 +57,7 @@ unsafe extern "C" fn json_object_boolean_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"true\\0" as *const u8 as *const ::core::ffi::c_char, + b"true\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -65,7 +65,7 @@ unsafe extern "C" fn json_object_boolean_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"false\\0" as *const u8 as *const ::core::ffi::c_char, + b"false\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 6]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/response.txt similarity index 84% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/response.txt index 0e0a151b6c..f50099b98a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/af52e24fd3a0407b548d38f8da2ca772f9af6247dd14f05e1a7f8cc11f284126/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_boolean_to_json_string/b574de1217f590cb51047f2d629095defbc23f68271a1114ac907d937c0714fa/response.txt @@ -8,14 +8,14 @@ unsafe extern "C" fn json_object_boolean_to_json_string( if (*jso).o.c_boolean != 0 { return printbuf_memappend( pb as *mut printbuf, - b"true\0" as *const u8 as *const ::core::ffi::c_char, + b"true\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } return printbuf_memappend( pb as *mut printbuf, - b"false\0" as *const u8 as *const ::core::ffi::c_char, + b"false\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 6]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/metadata.toml similarity index 95% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/metadata.toml index 20aa71ab1e..3b57a1d931 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/metadata.toml @@ -26,11 +26,11 @@ unsafe extern "C" fn json_object_copy_serializer_data( // else if ... other supported serializers ... else { _json_c_set_last_err( - b"json_object_deep_copy: unable to copy unknown serializer data: %p\\n\\0" as *const u8 + b"json_object_deep_copy: unable to copy unknown serializer data: %p\\n\\0".as_ptr() as *const ::core::ffi::c_char, (*dst)._to_json_string, ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*dst)._user_delete = (*src)._user_delete; return 0 as ::core::ffi::c_int; @@ -89,11 +89,11 @@ unsafe extern "C" fn json_object_copy_serializer_data( strdup((*src)._userdata as *const ::core::ffi::c_char) as *mut ::core::ffi::c_void; } else { _json_c_set_last_err( - b"json_object_deep_copy: unable to copy unknown serializer data: %p\\n\\0" as *const u8 + b"json_object_deep_copy: unable to copy unknown serializer data: %p\\n\\0".as_ptr() as *const ::core::ffi::c_char, (*dst)._to_json_string, ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*dst)._user_delete = (*src)._user_delete; return 0 as ::core::ffi::c_int; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/response.txt similarity index 93% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/response.txt index 095b054be0..e7558d58d4 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/b7f74e5916e3e57c85367a05b25c13f9ae8b9babe5e84474fde42a0936ea6705/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_copy_serializer_data/c552b1cba3b99c2c682bb6a44e077a7a63fae578c33567bb58e4e06ad0db5823/response.txt @@ -23,11 +23,11 @@ unsafe extern "C" fn json_object_copy_serializer_data( // else if ... other supported serializers ... else { _json_c_set_last_err( - b"json_object_deep_copy: unable to copy unknown serializer data: %p\n\0" as *const u8 + b"json_object_deep_copy: unable to copy unknown serializer data: %p\n\0".as_ptr() as *const ::core::ffi::c_char, (*dst)._to_json_string, ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*dst)._user_delete = (*src)._user_delete; return 0 as ::core::ffi::c_int; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/metadata.toml similarity index 91% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/metadata.toml index 7dc4fc42f4..33ff115aa6 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/metadata.toml @@ -1,18 +1,19 @@ transform = "CommentTransfer" identifier = "json_object_deep_copy" model = "gemini-3-flash-preview" -response = """#[no_mangle] +response = """```rust +#[no_mangle] + pub unsafe extern "C" fn json_object_deep_copy( mut src: *mut json_object, mut dst: *mut *mut json_object, mut shallow_copy: Option, ) -> ::core::ffi::c_int { let mut rc: ::core::ffi::c_int = 0; - - /* Check if arguments are sane ; *dst must not point to a non-NULL object */ + // Check if arguments are sane ; *dst must not point to a non-NULL object if src.is_null() || dst.is_null() || !(*dst).is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if shallow_copy.is_none() { shallow_copy = Some( @@ -30,7 +31,7 @@ pub unsafe extern "C" fn json_object_deep_copy( src, ::core::ptr::null_mut::(), ::core::ptr::null::<::core::ffi::c_char>(), - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, dst, shallow_copy, ); @@ -39,7 +40,8 @@ pub unsafe extern "C" fn json_object_deep_copy( *dst = ::core::ptr::null_mut::(); } return rc; -}""" +} +```""" [[messages]] role = "user" @@ -84,7 +86,7 @@ pub unsafe extern "C" fn json_object_deep_copy( let mut rc: ::core::ffi::c_int = 0; if src.is_null() || dst.is_null() || !(*dst).is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if shallow_copy.is_none() { shallow_copy = Some( @@ -102,7 +104,7 @@ pub unsafe extern "C" fn json_object_deep_copy( src, ::core::ptr::null_mut::(), ::core::ptr::null::<::core::ffi::c_char>(), - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, dst, shallow_copy, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/response.txt similarity index 86% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/response.txt index fb16b4eedd..2df4b63974 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/9339f049a13fda87fff5be725d42b86bb640dab9ff428baf59d6c49e17811abc/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy/f4e8cd2dbed693e2e7cde26c2a06d41dd3147b7fd60c03c1a87b0faf9d1f6035/response.txt @@ -1,15 +1,16 @@ +```rust #[no_mangle] + pub unsafe extern "C" fn json_object_deep_copy( mut src: *mut json_object, mut dst: *mut *mut json_object, mut shallow_copy: Option, ) -> ::core::ffi::c_int { let mut rc: ::core::ffi::c_int = 0; - - /* Check if arguments are sane ; *dst must not point to a non-NULL object */ + // Check if arguments are sane ; *dst must not point to a non-NULL object if src.is_null() || dst.is_null() || !(*dst).is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if shallow_copy.is_none() { shallow_copy = Some( @@ -27,7 +28,7 @@ pub unsafe extern "C" fn json_object_deep_copy( src, ::core::ptr::null_mut::(), ::core::ptr::null::<::core::ffi::c_char>(), - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, dst, shallow_copy, ); @@ -36,4 +37,5 @@ pub unsafe extern "C" fn json_object_deep_copy( *dst = ::core::ptr::null_mut::(); } return rc; -} \ No newline at end of file +} +``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/metadata.toml similarity index 91% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/metadata.toml index 246d2d8278..f4a7d92728 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/metadata.toml @@ -31,17 +31,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( /* -1=error, 1=object created ok, 2=userdata set */ if shallow_copy_rc < 1 as ::core::ffi::c_int { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } '_c2rust_label: { if !(*dst).is_null() { } else { __assert_fail( - b"*dst != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"*dst != NULL\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1426 as ::core::ffi::c_uint, b"int json_object_deep_copy_recursive(struct json_object *, struct json_object *, const char *, size_t, struct json_object **, json_c_shallow_copy_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -67,17 +67,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( iter.val as *mut json_object, src, iter.key, - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, &raw mut jso, shallow_copy, ) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_object_add(*dst, iter.key, jso) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -101,11 +101,11 @@ unsafe extern "C" fn json_object_deep_copy_recursive( ) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_array_add(*dst, jso_0) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } @@ -231,17 +231,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( ); if shallow_copy_rc < 1 as ::core::ffi::c_int { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } '_c2rust_label: { if !(*dst).is_null() { } else { __assert_fail( - b"*dst != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"*dst != NULL\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 1426 as ::core::ffi::c_uint, b"int json_object_deep_copy_recursive(struct json_object *, struct json_object *, const char *, size_t, struct json_object **, json_c_shallow_copy_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -266,17 +266,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( iter.val as *mut json_object, src, iter.key, - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, &raw mut jso, shallow_copy, ) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_object_add(*dst, iter.key, jso) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -299,11 +299,11 @@ unsafe extern "C" fn json_object_deep_copy_recursive( ) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_array_add(*dst, jso_0) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/response.txt similarity index 89% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/response.txt index 7acb275b6b..b03af146fd 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/65c5092e3fc2d1303e4885974bb6ed554289a4852b8229847f4dadc3b8178ba0/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_deep_copy_recursive/4a14fb83e75edaec6b5770a6bd0069858cf4a8ca6dec2b72057b5bff87b5779a/response.txt @@ -28,17 +28,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( /* -1=error, 1=object created ok, 2=userdata set */ if shallow_copy_rc < 1 as ::core::ffi::c_int { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } '_c2rust_label: { if !(*dst).is_null() { } else { __assert_fail( - b"*dst != NULL\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"*dst != NULL\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 1426 as ::core::ffi::c_uint, b"int json_object_deep_copy_recursive(struct json_object *, struct json_object *, const char *, size_t, struct json_object **, json_c_shallow_copy_fn *)\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -64,17 +64,17 @@ unsafe extern "C" fn json_object_deep_copy_recursive( iter.val as *mut json_object, src, iter.key, - -(1 as ::core::ffi::c_int) as size_t, + -1 as ::core::ffi::c_int as size_t, &raw mut jso, shallow_copy, ) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_object_add(*dst, iter.key, jso) < 0 as ::core::ffi::c_int { json_object_put(jso); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -98,11 +98,11 @@ unsafe extern "C" fn json_object_deep_copy_recursive( ) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if json_object_array_add(*dst, jso_0) < 0 as ::core::ffi::c_int { json_object_put(jso_0); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ii = ii.wrapping_add(1); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/metadata.toml similarity index 91% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/metadata.toml index 24f14f6ffc..302395f3e8 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/metadata.toml @@ -21,7 +21,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"NaN\\0" as *const u8 as *const ::core::ffi::c_char, + b"NaN\\0".as_ptr() as *const ::core::ffi::c_char, ); } else if if (*jso).o.c_double.is_infinite() { if (*jso).o.c_double.is_sign_positive() { @@ -37,18 +37,18 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"Infinity\\0" as *const u8 as *const ::core::ffi::c_char, + b"Infinity\\0".as_ptr() as *const ::core::ffi::c_char, ); } else { size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"-Infinity\\0" as *const u8 as *const ::core::ffi::c_char, + b"-Infinity\\0".as_ptr() as *const ::core::ffi::c_char, ); } } else { let mut std_format: *const ::core::ffi::c_char = - b"%.17g\\0" as *const u8 as *const ::core::ffi::c_char; + b"%.17g\\0".as_ptr() as *const ::core::ffi::c_char; let mut format_drops_decimals: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if format.is_null() { if !tls_serialization_float_format.is_null() { @@ -66,7 +66,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( (*jso).o.c_double, ); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } p = strchr(&raw mut buf as *mut ::core::ffi::c_char, ',' as i32); if !p.is_null() { @@ -75,7 +75,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( p = strchr(&raw mut buf as *mut ::core::ffi::c_char, '.' as i32); } if format == std_format - || strstr(format, b".0f\\0" as *const u8 as *const ::core::ffi::c_char).is_null() + || strstr(format, b".0f\\0".as_ptr() as *const ::core::ffi::c_char).is_null() { format_drops_decimals = 1 as ::core::ffi::c_int; } @@ -96,7 +96,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( // unless a custom format is set to omit the decimal. strcat( &raw mut buf as *mut ::core::ffi::c_char, - b".0\\0" as *const u8 as *const ::core::ffi::c_char, + b".0\\0".as_ptr() as *const ::core::ffi::c_char, ); size += 2 as ::core::ffi::c_int; } @@ -119,7 +119,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( } // although unlikely, snprintf can fail if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if size >= ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as ::core::ffi::c_int { // The standard formats are guaranteed not to overrun the buffer, @@ -247,7 +247,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"NaN\\0" as *const u8 as *const ::core::ffi::c_char, + b"NaN\\0".as_ptr() as *const ::core::ffi::c_char, ); } else if if (*jso).o.c_double.is_infinite() { if (*jso).o.c_double.is_sign_positive() { @@ -263,18 +263,18 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"Infinity\\0" as *const u8 as *const ::core::ffi::c_char, + b"Infinity\\0".as_ptr() as *const ::core::ffi::c_char, ); } else { size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"-Infinity\\0" as *const u8 as *const ::core::ffi::c_char, + b"-Infinity\\0".as_ptr() as *const ::core::ffi::c_char, ); } } else { let mut std_format: *const ::core::ffi::c_char = - b"%.17g\\0" as *const u8 as *const ::core::ffi::c_char; + b"%.17g\\0".as_ptr() as *const ::core::ffi::c_char; let mut format_drops_decimals: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if format.is_null() { if !tls_serialization_float_format.is_null() { @@ -292,7 +292,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( (*jso).o.c_double, ); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } p = strchr(&raw mut buf as *mut ::core::ffi::c_char, ',' as i32); if !p.is_null() { @@ -301,7 +301,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( p = strchr(&raw mut buf as *mut ::core::ffi::c_char, '.' as i32); } if format == std_format - || strstr(format, b".0f\\0" as *const u8 as *const ::core::ffi::c_char).is_null() + || strstr(format, b".0f\\0".as_ptr() as *const ::core::ffi::c_char).is_null() { format_drops_decimals = 1 as ::core::ffi::c_int; } @@ -320,7 +320,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( { strcat( &raw mut buf as *mut ::core::ffi::c_char, - b".0\\0" as *const u8 as *const ::core::ffi::c_char, + b".0\\0".as_ptr() as *const ::core::ffi::c_char, ); size += 2 as ::core::ffi::c_int; } @@ -340,7 +340,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( } } if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if size >= ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as ::core::ffi::c_int { size = (::core::mem::size_of::<[::core::ffi::c_char; 128]>() as usize) diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/response.txt similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/response.txt index c2e215e652..635ff559a3 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/0cc1d7d02c12f27e740543a9e364f63effd2ba55da2833d12860dc23488d9c44/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_double_to_json_string_format/4428421d37a1c1eadeebbd29873478a72c28deeb7d8ac6d379a748ce84119371/response.txt @@ -18,7 +18,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"NaN\0" as *const u8 as *const ::core::ffi::c_char, + b"NaN\0".as_ptr() as *const ::core::ffi::c_char, ); } else if if (*jso).o.c_double.is_infinite() { if (*jso).o.c_double.is_sign_positive() { @@ -34,18 +34,18 @@ unsafe extern "C" fn json_object_double_to_json_string_format( size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"Infinity\0" as *const u8 as *const ::core::ffi::c_char, + b"Infinity\0".as_ptr() as *const ::core::ffi::c_char, ); } else { size = snprintf( &raw mut buf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as size_t, - b"-Infinity\0" as *const u8 as *const ::core::ffi::c_char, + b"-Infinity\0".as_ptr() as *const ::core::ffi::c_char, ); } } else { let mut std_format: *const ::core::ffi::c_char = - b"%.17g\0" as *const u8 as *const ::core::ffi::c_char; + b"%.17g\0".as_ptr() as *const ::core::ffi::c_char; let mut format_drops_decimals: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if format.is_null() { if !tls_serialization_float_format.is_null() { @@ -63,7 +63,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( (*jso).o.c_double, ); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } p = strchr(&raw mut buf as *mut ::core::ffi::c_char, ',' as i32); if !p.is_null() { @@ -72,7 +72,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( p = strchr(&raw mut buf as *mut ::core::ffi::c_char, '.' as i32); } if format == std_format - || strstr(format, b".0f\0" as *const u8 as *const ::core::ffi::c_char).is_null() + || strstr(format, b".0f\0".as_ptr() as *const ::core::ffi::c_char).is_null() { format_drops_decimals = 1 as ::core::ffi::c_int; } @@ -93,7 +93,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( // unless a custom format is set to omit the decimal. strcat( &raw mut buf as *mut ::core::ffi::c_char, - b".0\0" as *const u8 as *const ::core::ffi::c_char, + b".0\0".as_ptr() as *const ::core::ffi::c_char, ); size += 2 as ::core::ffi::c_int; } @@ -116,7 +116,7 @@ unsafe extern "C" fn json_object_double_to_json_string_format( } // although unlikely, snprintf can fail if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if size >= ::core::mem::size_of::<[::core::ffi::c_char; 128]>() as ::core::ffi::c_int { // The standard formats are guaranteed not to overrun the buffer, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/metadata.toml similarity index 83% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/metadata.toml index 044402e288..f2dc3c2d35 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/metadata.toml @@ -12,10 +12,10 @@ pub unsafe extern "C" fn json_object_get(mut jso: *mut json_object) -> *mut json if (*jso)._ref_count < 4294967295 as uint32_t { } else { __assert_fail( - b"jso->_ref_count < UINT32_MAX\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count < UINT32_MAX\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 174 as ::core::ffi::c_uint, - b"struct json_object *json_object_get(struct json_object *)\\0" as *const u8 + b"struct json_object *json_object_get(struct json_object *)\\0".as_ptr() as *const ::core::ffi::c_char, ); } @@ -63,10 +63,10 @@ pub unsafe extern "C" fn json_object_get(mut jso: *mut json_object) -> *mut json if (*jso)._ref_count < 4294967295 as uint32_t { } else { __assert_fail( - b"jso->_ref_count < UINT32_MAX\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count < UINT32_MAX\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 174 as ::core::ffi::c_uint, - b"struct json_object *json_object_get(struct json_object *)\\0" as *const u8 + b"struct json_object *json_object_get(struct json_object *)\\0".as_ptr() as *const ::core::ffi::c_char, ); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/response.txt similarity index 74% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/response.txt index ea9380ebd1..702a781d26 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/cbf9a67e2406d554dd14b346a93b84b55fc01b8e96ddd05d57a9d1ab28ae8fe5/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_get/9981f58bd3bc4727e72b08053827315ca176487c152cf400dc797704d5888242/response.txt @@ -9,10 +9,10 @@ pub unsafe extern "C" fn json_object_get(mut jso: *mut json_object) -> *mut json if (*jso)._ref_count < 4294967295 as uint32_t { } else { __assert_fail( - b"jso->_ref_count < UINT32_MAX\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count < UINT32_MAX\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 174 as ::core::ffi::c_uint, - b"struct json_object *json_object_get(struct json_object *)\0" as *const u8 + b"struct json_object *json_object_get(struct json_object *)\0".as_ptr() as *const ::core::ffi::c_char, ); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/metadata.toml similarity index 94% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/metadata.toml index 66791c32ec..4200dac82b 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/metadata.toml @@ -13,7 +13,7 @@ unsafe extern "C" fn json_object_int_to_json_string( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 21]>() as size_t, - b"%ld\\0" as *const u8 as *const ::core::ffi::c_char, + b"%ld\\0".as_ptr() as *const ::core::ffi::c_char, (*jso).o.c_int64, ); return printbuf_memappend( @@ -57,7 +57,7 @@ unsafe extern "C" fn json_object_int_to_json_string( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 21]>() as size_t, - b"%ld\\0" as *const u8 as *const ::core::ffi::c_char, + b"%ld\\0".as_ptr() as *const ::core::ffi::c_char, (*jso).o.c_int64, ); return printbuf_memappend( diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/response.txt similarity index 92% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/response.txt index 70ee6b440d..38657276a5 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/c15d16dc9478e62f036cdfb80bdb7894f81bf53a09586492ab1aa447142fd2e7/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_int_to_json_string/1ae90acfdb51f307d336b1f27741c93f6578e074121c14bb667b95ab0e96e5a1/response.txt @@ -10,7 +10,7 @@ unsafe extern "C" fn json_object_int_to_json_string( snprintf( &raw mut sbuf as *mut ::core::ffi::c_char, ::core::mem::size_of::<[::core::ffi::c_char; 21]>() as size_t, - b"%ld\0" as *const u8 as *const ::core::ffi::c_char, + b"%ld\0".as_ptr() as *const ::core::ffi::c_char, (*jso).o.c_int64, ); return printbuf_memappend( diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/metadata.toml similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/metadata.toml index afdd76c8b8..553ea2af93 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/metadata.toml @@ -18,12 +18,12 @@ pub unsafe extern "C" fn json_object_object_add_ex( { } else { __assert_fail( - b"json_object_get_type(jso) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 479 as ::core::ffi::c_uint, b"int json_object_object_add_ex(struct json_object *, const char *const, struct json_object *const, const unsigned int)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -34,24 +34,30 @@ pub unsafe extern "C" fn json_object_object_add_ex( existing_entry = if opts & crate::src::json_object::JSON_C_OBJECT_ADD_KEY_IS_NEW as ::core::ffi::c_uint != 0 { ::core::ptr::null_mut::() } else { - lh_table_lookup_entry_w_hash((*jso).o.c_object as *mut lh_table, key as *const ::core::ffi::c_void, hash) as *mut lh_entry + lh_table_lookup_entry_w_hash( + (*jso).o.c_object as *mut lh_table, + key as *const ::core::ffi::c_void, + hash, + ) as *mut lh_entry }; // The caller must avoid creating loops in the object tree, but do a // quick check anyway to make sure we're not creating a trivial loop. if jso == val { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if existing_entry.is_null() { let k: *const ::core::ffi::c_void = - if opts & crate::src::json_object::JSON_C_OBJECT_KEY_IS_CONSTANT as ::core::ffi::c_uint != 0 { + if opts & crate::src::json_object::JSON_C_OBJECT_KEY_IS_CONSTANT as ::core::ffi::c_uint + != 0 + { key as *const ::core::ffi::c_void } else { strdup(key) as *const ::core::ffi::c_void }; if k.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return lh_table_insert_w_hash( (*jso).o.c_object as *mut lh_table, @@ -137,12 +143,12 @@ pub unsafe extern "C" fn json_object_object_add_ex( { } else { __assert_fail( - b"json_object_get_type(jso) == json_type_object\\0" as *const u8 + b"json_object_get_type(jso) == json_type_object\\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 479 as ::core::ffi::c_uint, b"int json_object_object_add_ex(struct json_object *, const char *const, struct json_object *const, const unsigned int)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -155,7 +161,7 @@ pub unsafe extern "C" fn json_object_object_add_ex( *mut lh_entry }; if jso == val { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if existing_entry.is_null() { let k: *const ::core::ffi::c_void = @@ -165,7 +171,7 @@ pub unsafe extern "C" fn json_object_object_add_ex( strdup(key) as *const ::core::ffi::c_void }; if k.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return lh_table_insert_w_hash( diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/response.txt similarity index 83% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/response.txt index 1a9942eee4..0835bc0259 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/f921c354b404fa97b0b4a8ba00c96835040e73debb375af3c5e2f9e7197feb6a/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_add_ex/7cb57ae1c800c6363f27048dee82bc79de6527b75a49fe07df9675a041c73995/response.txt @@ -15,12 +15,12 @@ pub unsafe extern "C" fn json_object_object_add_ex( { } else { __assert_fail( - b"json_object_get_type(jso) == json_type_object\0" as *const u8 + b"json_object_get_type(jso) == json_type_object\0".as_ptr() as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 479 as ::core::ffi::c_uint, b"int json_object_object_add_ex(struct json_object *, const char *const, struct json_object *const, const unsigned int)\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -31,24 +31,30 @@ pub unsafe extern "C" fn json_object_object_add_ex( existing_entry = if opts & crate::src::json_object::JSON_C_OBJECT_ADD_KEY_IS_NEW as ::core::ffi::c_uint != 0 { ::core::ptr::null_mut::() } else { - lh_table_lookup_entry_w_hash((*jso).o.c_object as *mut lh_table, key as *const ::core::ffi::c_void, hash) as *mut lh_entry + lh_table_lookup_entry_w_hash( + (*jso).o.c_object as *mut lh_table, + key as *const ::core::ffi::c_void, + hash, + ) as *mut lh_entry }; // The caller must avoid creating loops in the object tree, but do a // quick check anyway to make sure we're not creating a trivial loop. if jso == val { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if existing_entry.is_null() { let k: *const ::core::ffi::c_void = - if opts & crate::src::json_object::JSON_C_OBJECT_KEY_IS_CONSTANT as ::core::ffi::c_uint != 0 { + if opts & crate::src::json_object::JSON_C_OBJECT_KEY_IS_CONSTANT as ::core::ffi::c_uint + != 0 + { key as *const ::core::ffi::c_void } else { strdup(key) as *const ::core::ffi::c_void }; if k.is_null() { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return lh_table_insert_w_hash( (*jso).o.c_object as *mut lh_table, diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/metadata.toml similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/metadata.toml index c209a4309a..a7ca683f70 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/metadata.toml @@ -16,14 +16,14 @@ unsafe extern "C" fn json_object_object_to_json_string( }; printbuf_memappend( pb as *mut printbuf, - b"{\\0" as *const u8 as *const ::core::ffi::c_char, /*}*/ + b"{\\0".as_ptr() as *const ::core::ffi::c_char, /*}*/ (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); if flags & crate::src::json_object::JSON_C_TO_STRING_PRETTY != 0 { printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -43,14 +43,14 @@ unsafe extern "C" fn json_object_object_to_json_string( if had_children != 0 { printbuf_memappend( pb as *mut printbuf, - b",\\0" as *const u8 as *const ::core::ffi::c_char, + b",\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); if flags & crate::src::json_object::JSON_C_TO_STRING_PRETTY != 0 { printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -62,7 +62,7 @@ unsafe extern "C" fn json_object_object_to_json_string( { printbuf_memappend( pb as *mut printbuf, - b" \\0" as *const u8 as *const ::core::ffi::c_char, + b" \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -70,7 +70,7 @@ unsafe extern "C" fn json_object_object_to_json_string( indent(pb, level + 1 as ::core::ffi::c_int, flags); printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -78,14 +78,14 @@ unsafe extern "C" fn json_object_object_to_json_string( if flags & crate::src::json_object::JSON_C_TO_STRING_SPACED != 0 { printbuf_memappend( pb as *mut printbuf, - b"\\": \\0" as *const u8 as *const ::core::ffi::c_char, + b"\\": \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 4]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } else { printbuf_memappend( pb as *mut printbuf, - b"\\":\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\":\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -93,7 +93,7 @@ unsafe extern "C" fn json_object_object_to_json_string( if iter.val.is_null() { printbuf_memappend( pb as *mut printbuf, - b"null\\0" as *const u8 as *const ::core::ffi::c_char, + b"null\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -106,7 +106,7 @@ unsafe extern "C" fn json_object_object_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -114,7 +114,7 @@ unsafe extern "C" fn json_object_object_to_json_string( if had_children != 0 { printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -126,14 +126,14 @@ unsafe extern "C" fn json_object_object_to_json_string( { return printbuf_memappend( pb as *mut printbuf, - /*{*/ b" }\\0" as *const u8 as *const ::core::ffi::c_char, + /*{*/ b" }\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } else { return printbuf_memappend( pb as *mut printbuf, - /*{*/ b"}\\0" as *const u8 as *const ::core::ffi::c_char, + /*{*/ b"}\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -215,7 +215,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"{\\0" as *const u8 as *const ::core::ffi::c_char, + b"{\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -223,7 +223,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -244,7 +244,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b",\\0" as *const u8 as *const ::core::ffi::c_char, + b",\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -252,7 +252,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -263,7 +263,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b" \\0" as *const u8 as *const ::core::ffi::c_char, + b" \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -272,7 +272,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -281,7 +281,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\": \\0" as *const u8 as *const ::core::ffi::c_char, + b"\\": \\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 4]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -289,7 +289,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\":\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\":\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -298,7 +298,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"null\\0" as *const u8 as *const ::core::ffi::c_char, + b"null\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -311,7 +311,7 @@ unsafe extern "C" fn json_object_object_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -320,7 +320,7 @@ unsafe extern "C" fn json_object_object_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\n\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -331,7 +331,7 @@ unsafe extern "C" fn json_object_object_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b" }\\0" as *const u8 as *const ::core::ffi::c_char, + b" }\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -339,7 +339,7 @@ unsafe extern "C" fn json_object_object_to_json_string( return printbuf_memappend( pb as *mut printbuf, - b"}\\0" as *const u8 as *const ::core::ffi::c_char, + b"}\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/response.txt similarity index 85% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/response.txt index 73f873ad71..16e6310278 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/d675199bc1ff9e917bb1c7e3d7159745764077078abf63dd348ac86ed38d1c02/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_object_to_json_string/68f1e033fca48a74c6790c046b6eb4f7f77cfac3674f1f4cc5ba201337750bfc/response.txt @@ -13,14 +13,14 @@ unsafe extern "C" fn json_object_object_to_json_string( }; printbuf_memappend( pb as *mut printbuf, - b"{\0" as *const u8 as *const ::core::ffi::c_char, /*}*/ + b"{\0".as_ptr() as *const ::core::ffi::c_char, /*}*/ (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); if flags & crate::src::json_object::JSON_C_TO_STRING_PRETTY != 0 { printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -40,14 +40,14 @@ unsafe extern "C" fn json_object_object_to_json_string( if had_children != 0 { printbuf_memappend( pb as *mut printbuf, - b",\0" as *const u8 as *const ::core::ffi::c_char, + b",\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); if flags & crate::src::json_object::JSON_C_TO_STRING_PRETTY != 0 { printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -59,7 +59,7 @@ unsafe extern "C" fn json_object_object_to_json_string( { printbuf_memappend( pb as *mut printbuf, - b" \0" as *const u8 as *const ::core::ffi::c_char, + b" \0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -67,7 +67,7 @@ unsafe extern "C" fn json_object_object_to_json_string( indent(pb, level + 1 as ::core::ffi::c_int, flags); printbuf_memappend( pb as *mut printbuf, - b"\"\0" as *const u8 as *const ::core::ffi::c_char, + b"\"\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -75,14 +75,14 @@ unsafe extern "C" fn json_object_object_to_json_string( if flags & crate::src::json_object::JSON_C_TO_STRING_SPACED != 0 { printbuf_memappend( pb as *mut printbuf, - b"\": \0" as *const u8 as *const ::core::ffi::c_char, + b"\": \0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 4]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } else { printbuf_memappend( pb as *mut printbuf, - b"\":\0" as *const u8 as *const ::core::ffi::c_char, + b"\":\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -90,7 +90,7 @@ unsafe extern "C" fn json_object_object_to_json_string( if iter.val.is_null() { printbuf_memappend( pb as *mut printbuf, - b"null\0" as *const u8 as *const ::core::ffi::c_char, + b"null\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 5]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -103,7 +103,7 @@ unsafe extern "C" fn json_object_object_to_json_string( flags, ) < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } iter.entry = (*iter.entry).next as *mut lh_entry; } @@ -111,7 +111,7 @@ unsafe extern "C" fn json_object_object_to_json_string( if had_children != 0 { printbuf_memappend( pb as *mut printbuf, - b"\n\0" as *const u8 as *const ::core::ffi::c_char, + b"\n\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize) .wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -123,14 +123,14 @@ unsafe extern "C" fn json_object_object_to_json_string( { return printbuf_memappend( pb as *mut printbuf, - /*{*/ b" }\0" as *const u8 as *const ::core::ffi::c_char, + /*{*/ b" }\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 3]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); } else { return printbuf_memappend( pb as *mut printbuf, - /*{*/ b"}\0" as *const u8 as *const ::core::ffi::c_char, + /*{*/ b"}\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/metadata.toml similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/metadata.toml index 59a8e3f620..422c4cc239 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/metadata.toml @@ -14,10 +14,10 @@ pub unsafe extern "C" fn json_object_put(mut jso: *mut json_object) -> ::core::f if (*jso)._ref_count > 0 as uint32_t { } else { __assert_fail( - b"jso->_ref_count > 0\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count > 0\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 192 as ::core::ffi::c_uint, - b"int json_object_put(struct json_object *)\\0" as *const u8 + b"int json_object_put(struct json_object *)\\0".as_ptr() as *const ::core::ffi::c_char, ); } @@ -88,10 +88,10 @@ pub unsafe extern "C" fn json_object_put(mut jso: *mut json_object) -> ::core::f if (*jso)._ref_count > 0 as uint32_t { } else { __assert_fail( - b"jso->_ref_count > 0\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count > 0\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 192 as ::core::ffi::c_uint, - b"int json_object_put(struct json_object *)\\0" as *const u8 + b"int json_object_put(struct json_object *)\\0".as_ptr() as *const ::core::ffi::c_char, ); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/response.txt similarity index 83% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/response.txt index d7a7813a2f..2369f20e90 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/41b68a7cb55c1f87e484d2520f3dc62e104429f6b367c571a54f24f66f9791ec/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_put/81f321b54820741da875d23bbb9a5c15ad3353e015f2df4a24ace926d4c24ccb/response.txt @@ -11,10 +11,10 @@ pub unsafe extern "C" fn json_object_put(mut jso: *mut json_object) -> ::core::f if (*jso)._ref_count > 0 as uint32_t { } else { __assert_fail( - b"jso->_ref_count > 0\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"jso->_ref_count > 0\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 192 as ::core::ffi::c_uint, - b"int json_object_put(struct json_object *)\0" as *const u8 + b"int json_object_put(struct json_object *)\0".as_ptr() as *const ::core::ffi::c_char, ); } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/metadata.toml deleted file mode 100644 index 8f9ff7a793..0000000000 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/metadata.toml +++ /dev/null @@ -1,109 +0,0 @@ -transform = "CommentTransfer" -identifier = "json_object_set_userdata" -model = "gemini-3-flash-preview" -response = """```rust -#[no_mangle] -pub unsafe extern "C" fn json_object_set_userdata( - mut jso: *mut json_object, - mut userdata: *mut ::core::ffi::c_void, - mut user_delete: Option, -) { - // Can't return failure, so abort if we can't perform the operation. - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - 'c_865: { - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - }; - // First, clean up any previously existing user info - if (*jso)._user_delete.is_some() { - (*jso)._user_delete.expect("non-null function pointer")( - jso as *mut json_object, - (*jso)._userdata, - ); - } - (*jso)._userdata = userdata; - (*jso)._user_delete = user_delete; -} -```""" - -[[messages]] -role = "user" -content = """Transfer the comments from the following C function to the corresponding Rust function. -Do not add any comments that are not present in the C function. -Use Rust doc comment syntax (///) where appropriate (e.g., for function documentation). -Respond with the Rust function definition with the transferred comments; say nothing else. - -C function: -```c -void json_object_set_userdata(json_object *jso, void *userdata, -\t\t\t json_object_delete_fn *user_delete) -{ -\t// Can't return failure, so abort if we can't perform the operation. -\tassert(jso != NULL); - -\t// First, clean up any previously existing user info -\tif (jso->_user_delete) -\t\tjso->_user_delete(jso, jso->_userdata); - -\tjso->_userdata = userdata; -\tjso->_user_delete = user_delete; -}``` - -Rust function: -```rust -#[no_mangle] - -pub unsafe extern "C" fn json_object_set_userdata( - mut jso: *mut json_object, - mut userdata: *mut ::core::ffi::c_void, - mut user_delete: Option, -) { - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - 'c_865: { - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - }; - if (*jso)._user_delete.is_some() { - (*jso)._user_delete.expect("non-null function pointer")( - jso as *mut json_object, - (*jso)._userdata, - ); - } - (*jso)._userdata = userdata; - (*jso)._user_delete = user_delete; -}``` -""" diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/response.txt deleted file mode 100644 index 38d1105fec..0000000000 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/8540ec3938a2ebb6f647af77dbbb0c476d18be95229ef15bcf0426cf4ad5e131/response.txt +++ /dev/null @@ -1,41 +0,0 @@ -```rust -#[no_mangle] -pub unsafe extern "C" fn json_object_set_userdata( - mut jso: *mut json_object, - mut userdata: *mut ::core::ffi::c_void, - mut user_delete: Option, -) { - // Can't return failure, so abort if we can't perform the operation. - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - 'c_865: { - if !jso.is_null() { - } else { - __assert_fail( - b"jso != NULL\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, - 268 as ::core::ffi::c_uint, - b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\0" - as *const u8 as *const ::core::ffi::c_char, - ); - } - }; - // First, clean up any previously existing user info - if (*jso)._user_delete.is_some() { - (*jso)._user_delete.expect("non-null function pointer")( - jso as *mut json_object, - (*jso)._userdata, - ); - } - (*jso)._userdata = userdata; - (*jso)._user_delete = user_delete; -} -``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/metadata.toml similarity index 85% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/metadata.toml index f1166eabc4..cd650c3f9f 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/metadata.toml @@ -13,11 +13,11 @@ pub unsafe extern "C" fn json_object_set_userdata( if !jso.is_null() { } else { __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso != NULL\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 268 as ::core::ffi::c_uint, b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; @@ -69,11 +69,11 @@ pub unsafe extern "C" fn json_object_set_userdata( if !jso.is_null() { } else { __assert_fail( - b"jso != NULL\\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\\0" as *const u8 as *const ::core::ffi::c_char, + b"jso != NULL\\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\\0".as_ptr() as *const ::core::ffi::c_char, 268 as ::core::ffi::c_uint, b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/response.txt similarity index 80% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/response.txt index 8948cbd072..ba453596ac 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/6785f81686954ff3eb20593707d9c49de1092d4c66befd08fde31a62be28e6dc/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_set_userdata/b969c1ea3af95e15602df795d5904f50b5913393d33dd5477a37d386ffa1fd15/response.txt @@ -10,11 +10,11 @@ pub unsafe extern "C" fn json_object_set_userdata( if !jso.is_null() { } else { __assert_fail( - b"jso != NULL\0" as *const u8 as *const ::core::ffi::c_char, - b"json_object.c\0" as *const u8 as *const ::core::ffi::c_char, + b"jso != NULL\0".as_ptr() as *const ::core::ffi::c_char, + b"json_object.c\0".as_ptr() as *const ::core::ffi::c_char, 268 as ::core::ffi::c_uint, b"void json_object_set_userdata(json_object *, void *, json_object_delete_fn *)\0" - as *const u8 as *const ::core::ffi::c_char, + .as_ptr() as *const ::core::ffi::c_char, ); } }; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/metadata.toml similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/metadata.toml index 15db69312c..2eab7cdb4f 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/metadata.toml @@ -10,14 +10,14 @@ unsafe extern "C" fn json_object_string_to_json_string( ) -> ::core::ffi::c_int { printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); json_escape_str(pb, get_string_component(jso), (*jso).o.c_string.len, flags); printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -57,7 +57,7 @@ unsafe extern "C" fn json_object_string_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); @@ -65,7 +65,7 @@ unsafe extern "C" fn json_object_string_to_json_string( printbuf_memappend( pb as *mut printbuf, - b"\\"\\0" as *const u8 as *const ::core::ffi::c_char, + b"\\"\\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/response.txt similarity index 85% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/response.txt index 12ddfd9126..6afd346fa6 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/8e3235cbf62b4167b46c78f742446c905190b847c494721191a2daa32f31af94/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_string_to_json_string/41e99b772e310b29e0c992d489f9046b22b01145dd4bb92b793003ee025e2380/response.txt @@ -7,14 +7,14 @@ unsafe extern "C" fn json_object_string_to_json_string( ) -> ::core::ffi::c_int { printbuf_memappend( pb as *mut printbuf, - b"\"\0" as *const u8 as *const ::core::ffi::c_char, + b"\"\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); json_escape_str(pb, get_string_component(jso), (*jso).o.c_string.len, flags); printbuf_memappend( pb as *mut printbuf, - b"\"\0" as *const u8 as *const ::core::ffi::c_char, + b"\"\0".as_ptr() as *const ::core::ffi::c_char, (::core::mem::size_of::<[::core::ffi::c_char; 2]>() as usize).wrapping_sub(1 as usize) as ::core::ffi::c_int, ); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/metadata.toml similarity index 88% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/metadata.toml index 7266586722..53c59912ea 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/metadata.toml @@ -13,9 +13,9 @@ pub unsafe extern "C" fn json_object_to_file_ext( let mut saved_errno: ::core::ffi::c_int = 0; if obj.is_null() { _json_c_set_last_err( - b"json_object_to_file: object is null\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object_to_file: object is null\\n\\0".as_ptr() as *const ::core::ffi::c_char ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } fd = open( filename, @@ -24,12 +24,12 @@ pub unsafe extern "C" fn json_object_to_file_ext( ); if fd < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error opening file %s: %s\\n\\0" as *const u8 + b"json_object_to_file: error opening file %s: %s\\n\\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ret = _json_object_to_fd(fd, obj, flags, filename); saved_errno = *__errno_location(); @@ -85,9 +85,9 @@ pub unsafe extern "C" fn json_object_to_file_ext( let mut saved_errno: ::core::ffi::c_int = 0; if obj.is_null() { _json_c_set_last_err( - b"json_object_to_file: object is null\\n\\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object_to_file: object is null\\n\\0".as_ptr() as *const ::core::ffi::c_char ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } fd = open( filename, @@ -96,12 +96,12 @@ pub unsafe extern "C" fn json_object_to_file_ext( ); if fd < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error opening file %s: %s\\n\\0" as *const u8 + b"json_object_to_file: error opening file %s: %s\\n\\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ret = _json_object_to_fd(fd, obj, flags, filename); saved_errno = *__errno_location(); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/response.txt similarity index 83% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/response.txt index 516f351c51..f4facff350 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/1a05b089f7ad6666317d4d22bd44081ca8d7626b548d86ecbd0e36ae0f7ff84f/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_file_ext/4f134fac5fd9787469ed4c7909251d4f4465859f99016e53e523744aa16d53f9/response.txt @@ -10,9 +10,9 @@ pub unsafe extern "C" fn json_object_to_file_ext( let mut saved_errno: ::core::ffi::c_int = 0; if obj.is_null() { _json_c_set_last_err( - b"json_object_to_file: object is null\n\0" as *const u8 as *const ::core::ffi::c_char, + b"json_object_to_file: object is null\n\0".as_ptr() as *const ::core::ffi::c_char ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } fd = open( filename, @@ -21,12 +21,12 @@ pub unsafe extern "C" fn json_object_to_file_ext( ); if fd < 0 as ::core::ffi::c_int { _json_c_set_last_err( - b"json_object_to_file: error opening file %s: %s\n\0" as *const u8 + b"json_object_to_file: error opening file %s: %s\n\0".as_ptr() as *const ::core::ffi::c_char, filename, _json_c_strerror(*__errno_location()), ); - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ret = _json_object_to_fd(fd, obj, flags, filename); saved_errno = *__errno_location(); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/metadata.toml similarity index 93% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/metadata.toml index e36d22ab10..02f0bbc825 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/metadata.toml @@ -3,7 +3,6 @@ identifier = "json_object_to_json_string_length" model = "gemini-3-flash-preview" response = """/// extended conversion to string #[no_mangle] - pub unsafe extern "C" fn json_object_to_json_string_length( mut jso: *mut json_object, mut flags: ::core::ffi::c_int, @@ -13,9 +12,9 @@ pub unsafe extern "C" fn json_object_to_json_string_length( let mut s: size_t = 0 as size_t; if jso.is_null() { s = 4 as size_t; - r = b"null\\0" as *const u8 as *const ::core::ffi::c_char; + r = b"null\\0".as_ptr() as *const ::core::ffi::c_char; } else if !(*jso)._pb.is_null() || { - (*jso)._pb = printbuf_new() as *mut printbuf; + (*jso)._pb = printbuf_new() as *mut printbuf; !(*jso)._pb.is_null() } { printbuf_reset((*jso)._pb as *mut printbuf); @@ -86,7 +85,7 @@ pub unsafe extern "C" fn json_object_to_json_string_length( let mut s: size_t = 0 as size_t; if jso.is_null() { s = 4 as size_t; - r = b"null\\0" as *const u8 as *const ::core::ffi::c_char; + r = b"null\\0".as_ptr() as *const ::core::ffi::c_char; } else if !(*jso)._pb.is_null() || { (*jso)._pb = printbuf_new() as *mut printbuf; !(*jso)._pb.is_null() diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/response.txt similarity index 88% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/response.txt index 862d52879f..8d38c1af9e 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/b212382c7c5b86e3b4892ff29c9921fcf35a1d855ab1304d3ffc0fbde3799414/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_object_to_json_string_length/6cc8de8b642806a255175919aff69cad60e0db8b93272cd49e6ed9a3cdb4bb47/response.txt @@ -1,6 +1,5 @@ /// extended conversion to string #[no_mangle] - pub unsafe extern "C" fn json_object_to_json_string_length( mut jso: *mut json_object, mut flags: ::core::ffi::c_int, @@ -10,9 +9,9 @@ pub unsafe extern "C" fn json_object_to_json_string_length( let mut s: size_t = 0 as size_t; if jso.is_null() { s = 4 as size_t; - r = b"null\0" as *const u8 as *const ::core::ffi::c_char; + r = b"null\0".as_ptr() as *const ::core::ffi::c_char; } else if !(*jso)._pb.is_null() || { - (*jso)._pb = printbuf_new() as *mut printbuf; + (*jso)._pb = printbuf_new() as *mut printbuf; !(*jso)._pb.is_null() } { printbuf_reset((*jso)._pb as *mut printbuf); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/metadata.toml similarity index 92% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/metadata.toml index a6a429ad1a..bab799e9c5 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/metadata.toml @@ -1,9 +1,7 @@ transform = "CommentTransfer" identifier = "json_pointer_get" model = "gemini-3-flash-preview" -response = """```rust -#[no_mangle] - +response = """#[no_mangle] pub unsafe extern "C" fn json_pointer_get( mut obj: *mut json_object, mut path: *const ::core::ffi::c_char, @@ -13,7 +11,7 @@ pub unsafe extern "C" fn json_pointer_get( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { if !res.is_null() { @@ -25,13 +23,12 @@ pub unsafe extern "C" fn json_pointer_get( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } rc = json_pointer_get_recursive(obj, path_copy, res); free(path_copy as *mut ::core::ffi::c_void); return rc; -} -```""" +}""" [[messages]] role = "user" @@ -82,7 +79,7 @@ pub unsafe extern "C" fn json_pointer_get( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { if !res.is_null() { @@ -93,7 +90,7 @@ pub unsafe extern "C" fn json_pointer_get( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } rc = json_pointer_get_recursive(obj, path_copy, res); free(path_copy as *mut ::core::ffi::c_void); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/response.txt similarity index 89% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/response.txt index 06a4be82cb..b24ec92399 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/e4b4ea02b7ab4dbaab52930d1d7a4324f661ec35df2e8b8716679083ebcc62b0/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get/a7099329d95e7d1fc76d692fbf793694dc7157227509f4b64d120a8d7b020b80/response.txt @@ -1,6 +1,4 @@ -```rust #[no_mangle] - pub unsafe extern "C" fn json_pointer_get( mut obj: *mut json_object, mut path: *const ::core::ffi::c_char, @@ -10,7 +8,7 @@ pub unsafe extern "C" fn json_pointer_get( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\0' as i32 { if !res.is_null() { @@ -22,10 +20,9 @@ pub unsafe extern "C" fn json_pointer_get( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } rc = json_pointer_get_recursive(obj, path_copy, res); free(path_copy as *mut ::core::ffi::c_void); return rc; -} -``` \ No newline at end of file +} \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/metadata.toml similarity index 97% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/metadata.toml index e470fe166c..551b0f1bdb 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/metadata.toml @@ -13,7 +13,7 @@ unsafe extern "C" fn json_pointer_get_recursive( /* All paths (on each recursion level must have a leading '/' */ if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } path = path.offset(1); @@ -97,7 +97,7 @@ unsafe extern "C" fn json_pointer_get_recursive( let mut rc: ::core::ffi::c_int = 0; if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } path = path.offset(1); endp = strchr(path, '/' as i32); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/response.txt similarity index 96% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/response.txt index 9717d258e1..6ec6a2841a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/59a2809f8a753257036c9490bedc48afe3d37c23fcc14c8787c11969050eac5c/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_recursive/5bb679e108061fb99b6f867642cf5a6cfa52a8aa5eafd977526de4fd670ca329/response.txt @@ -10,7 +10,7 @@ unsafe extern "C" fn json_pointer_get_recursive( /* All paths (on each recursion level must have a leading '/' */ if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } path = path.offset(1); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/metadata.toml similarity index 86% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/metadata.toml index 3ec4bb1464..113cb2de4f 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/metadata.toml @@ -10,7 +10,7 @@ unsafe extern "C" fn json_pointer_get_single_path( if json_object_is_type(obj, json_type_array) != 0 { let mut idx: int32_t = 0; if is_valid_index(obj, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } obj = json_object_array_get_idx(obj, idx as size_t); if !obj.is_null() { @@ -21,23 +21,22 @@ unsafe extern "C" fn json_pointer_get_single_path( } /* Entry not found */ *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } - /* RFC states that we first must eval all ~1 then all ~0 */ string_replace_all_occurrences_with_char( path, - b"~1\\0" as *const u8 as *const ::core::ffi::c_char, + b"~1\\0".as_ptr() as *const ::core::ffi::c_char, '/' as i32 as ::core::ffi::c_char, ); string_replace_all_occurrences_with_char( path, - b"~0\\0" as *const u8 as *const ::core::ffi::c_char, + b"~0\\0".as_ptr() as *const ::core::ffi::c_char, '~' as i32 as ::core::ffi::c_char, ); if json_object_object_get_ex(obj, path, value) == 0 { *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return 0 as ::core::ffi::c_int; } @@ -91,7 +90,7 @@ unsafe extern "C" fn json_pointer_get_single_path( if json_object_is_type(obj, json_type_array) != 0 { let mut idx: int32_t = 0; if is_valid_index(obj, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } obj = json_object_array_get_idx(obj, idx as size_t); if !obj.is_null() { @@ -101,21 +100,21 @@ unsafe extern "C" fn json_pointer_get_single_path( return 0 as ::core::ffi::c_int; } *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } string_replace_all_occurrences_with_char( path, - b"~1\\0" as *const u8 as *const ::core::ffi::c_char, + b"~1\\0".as_ptr() as *const ::core::ffi::c_char, '/' as i32 as ::core::ffi::c_char, ); string_replace_all_occurrences_with_char( path, - b"~0\\0" as *const u8 as *const ::core::ffi::c_char, + b"~0\\0".as_ptr() as *const ::core::ffi::c_char, '~' as i32 as ::core::ffi::c_char, ); if json_object_object_get_ex(obj, path, value) == 0 { *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return 0 as ::core::ffi::c_int; }``` diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/response.txt similarity index 80% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/response.txt index 15a29cd5f4..23fae18c85 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/0d0542afbf8c17253e9d6ca9754615ae49185016e109c5da0bbe88212e5d20be/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_get_single_path/cdc517c662d5c056a01e3c2d28859d749f8f7f980192d8840840f9642a55b817/response.txt @@ -7,7 +7,7 @@ unsafe extern "C" fn json_pointer_get_single_path( if json_object_is_type(obj, json_type_array) != 0 { let mut idx: int32_t = 0; if is_valid_index(obj, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } obj = json_object_array_get_idx(obj, idx as size_t); if !obj.is_null() { @@ -18,23 +18,22 @@ unsafe extern "C" fn json_pointer_get_single_path( } /* Entry not found */ *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } - /* RFC states that we first must eval all ~1 then all ~0 */ string_replace_all_occurrences_with_char( path, - b"~1\0" as *const u8 as *const ::core::ffi::c_char, + b"~1\0".as_ptr() as *const ::core::ffi::c_char, '/' as i32 as ::core::ffi::c_char, ); string_replace_all_occurrences_with_char( path, - b"~0\0" as *const u8 as *const ::core::ffi::c_char, + b"~0\0".as_ptr() as *const ::core::ffi::c_char, '~' as i32 as ::core::ffi::c_char, ); if json_object_object_get_ex(obj, path, value) == 0 { *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return 0 as ::core::ffi::c_int; } diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/metadata.toml similarity index 94% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/metadata.toml index 6450a7b3bc..1c2f58c1e7 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/metadata.toml @@ -3,6 +3,7 @@ identifier = "json_pointer_set" model = "gemini-3-flash-preview" response = """```rust #[no_mangle] + pub unsafe extern "C" fn json_pointer_set( mut obj: *mut *mut json_object, mut path: *const ::core::ffi::c_char, @@ -14,7 +15,7 @@ pub unsafe extern "C" fn json_pointer_set( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { json_object_put(*obj); @@ -23,7 +24,7 @@ pub unsafe extern "C" fn json_pointer_set( } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } /* If there's only 1 level to set, stop here */ endp = strrchr(path, '/' as i32); @@ -35,7 +36,7 @@ pub unsafe extern "C" fn json_pointer_set( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } *path_copy.offset(endp.offset_from(path) as ::core::ffi::c_long as isize) = '\\0' as i32 as ::core::ffi::c_char; @@ -118,7 +119,7 @@ pub unsafe extern "C" fn json_pointer_set( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { json_object_put(*obj); @@ -127,7 +128,7 @@ pub unsafe extern "C" fn json_pointer_set( } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } endp = strrchr(path, '/' as i32); if endp == path { @@ -137,7 +138,7 @@ pub unsafe extern "C" fn json_pointer_set( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } *path_copy.offset(endp.offset_from(path) as ::core::ffi::c_long as isize) = '\\0' as i32 as ::core::ffi::c_char; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/response.txt similarity index 92% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/response.txt index 7304070d77..d102022148 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/76289070ebe48774343f419d89fc44805ca1ff57e26b11d78a1f9c7db717917e/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set/ee35cb10fa4d5df4468a0c33a68166459df5b7d46354e74329ca60b697dbbcbd/response.txt @@ -1,5 +1,6 @@ ```rust #[no_mangle] + pub unsafe extern "C" fn json_pointer_set( mut obj: *mut *mut json_object, mut path: *const ::core::ffi::c_char, @@ -11,7 +12,7 @@ pub unsafe extern "C" fn json_pointer_set( let mut rc: ::core::ffi::c_int = 0; if obj.is_null() || path.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\0' as i32 { json_object_put(*obj); @@ -20,7 +21,7 @@ pub unsafe extern "C" fn json_pointer_set( } if *path.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int != '/' as i32 { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } /* If there's only 1 level to set, stop here */ endp = strrchr(path, '/' as i32); @@ -32,7 +33,7 @@ pub unsafe extern "C" fn json_pointer_set( path_copy = strdup(path); if path_copy.is_null() { *__errno_location() = ENOMEM; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } *path_copy.offset(endp.offset_from(path) as ::core::ffi::c_long as isize) = '\0' as i32 as ::core::ffi::c_char; diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/metadata.toml similarity index 93% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/metadata.toml index aa05c806eb..ffe59bbdaa 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/metadata.toml @@ -16,21 +16,21 @@ unsafe extern "C" fn json_pointer_set_single_path( return json_object_array_add(parent, value); } if is_valid_index(parent, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return json_object_array_put_idx(parent, idx as size_t, value); } /* path replacements should have been done in json_pointer_get_single_path(), - and we should still be good here */ +\t and we should still be good here */ if json_object_is_type(parent, json_type_object) != 0 { return json_object_object_add(parent, path, value); } /* Getting here means that we tried to "dereference" a primitive JSON type (like string, int, bool). - i.e. add a sub-object to it */ +\t i.e. add a sub-object to it */ *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ```""" @@ -84,7 +84,7 @@ unsafe extern "C" fn json_pointer_set_single_path( return json_object_array_add(parent, value); } if is_valid_index(parent, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return json_object_array_put_idx(parent, idx as size_t, value); } @@ -92,6 +92,6 @@ unsafe extern "C" fn json_pointer_set_single_path( return json_object_object_add(parent, path, value); } *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; }``` """ diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/response.txt similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/response.txt index ceca6f720e..8c0e072cf4 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/79be311d333429233ae9ef91d3564b090dc362e0dca4d8f833a76aa79f75a475/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_set_single_path/fa4907a244c7588ae91637f693a267fb0b3582a73b2ab48ce13eae80eeb217a0/response.txt @@ -13,20 +13,20 @@ unsafe extern "C" fn json_pointer_set_single_path( return json_object_array_add(parent, value); } if is_valid_index(parent, path, &raw mut idx) == 0 { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } return json_object_array_put_idx(parent, idx as size_t, value); } /* path replacements should have been done in json_pointer_get_single_path(), - and we should still be good here */ + and we should still be good here */ if json_object_is_type(parent, json_type_object) != 0 { return json_object_object_add(parent, path, value); } /* Getting here means that we tried to "dereference" a primitive JSON type (like string, int, bool). - i.e. add a sub-object to it */ + i.e. add a sub-object to it */ *__errno_location() = ENOENT; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } ``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/metadata.toml similarity index 80% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/metadata.toml index dc830f320c..661ad7befc 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/metadata.toml @@ -1,27 +1,26 @@ transform = "CommentTransfer" identifier = "json_pointer_setf" model = "gemini-3-flash-preview" -response = """```rust -#[no_mangle] +response = """#[no_mangle] pub unsafe extern "C" fn json_pointer_setf( mut obj: *mut *mut json_object, mut value: *mut json_object, mut path_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { - let mut current_block: u64; + let mut c2rust_current_block: u64; let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut set: *mut json_object = ::core::ptr::null_mut::(); - let mut args_0: ::core::ffi::VaListImpl; + let mut args: ::core::ffi::VaListImpl; let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if obj.is_null() || path_fmt.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } /* pass a working copy to the recursive call */ - args_0 = args.clone(); - rc = vasprintf(&raw mut path_copy, path_fmt, args_0.as_va_list()); + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); if rc < 0 as ::core::ffi::c_int { return rc; } @@ -32,24 +31,24 @@ pub unsafe extern "C" fn json_pointer_setf( != '/' as i32 { *__errno_location() = EINVAL; - rc = -(1 as ::core::ffi::c_int); + rc = -1 as ::core::ffi::c_int; } else { /* If there's only 1 level to set, stop here */ endp = strrchr(path_copy, '/' as i32); if endp == path_copy { set = *obj; - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } else { *endp = '\\0' as i32 as ::core::ffi::c_char; rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); if rc != 0 { - current_block = 4724740344109054664; + c2rust_current_block = 13203993160948060081; } else { - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } } - match current_block { - 4724740344109054664 => {} + match c2rust_current_block { + 13203993160948060081 => {} _ => { endp = endp.offset(1); rc = json_pointer_set_single_path(set, endp, value); @@ -58,8 +57,7 @@ pub unsafe extern "C" fn json_pointer_setf( } free(path_copy as *mut ::core::ffi::c_void); return rc; -} -```""" +}""" [[messages]] role = "user" @@ -131,20 +129,20 @@ pub unsafe extern "C" fn json_pointer_setf( mut obj: *mut *mut json_object, mut value: *mut json_object, mut path_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { - let mut current_block: u64; + let mut c2rust_current_block: u64; let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut set: *mut json_object = ::core::ptr::null_mut::(); - let mut args_0: ::core::ffi::VaListImpl; + let mut args: ::core::ffi::VaListImpl; let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if obj.is_null() || path_fmt.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } - args_0 = args.clone(); - rc = vasprintf(&raw mut path_copy, path_fmt, args_0.as_va_list()); + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); if rc < 0 as ::core::ffi::c_int { return rc; } @@ -155,23 +153,23 @@ pub unsafe extern "C" fn json_pointer_setf( != '/' as i32 { *__errno_location() = EINVAL; - rc = -(1 as ::core::ffi::c_int); + rc = -1 as ::core::ffi::c_int; } else { endp = strrchr(path_copy, '/' as i32); if endp == path_copy { set = *obj; - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } else { *endp = '\\0' as i32 as ::core::ffi::c_char; rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); if rc != 0 { - current_block = 4724740344109054664; + c2rust_current_block = 13203993160948060081; } else { - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } } - match current_block { - 4724740344109054664 => {} + match c2rust_current_block { + 13203993160948060081 => {} _ => { endp = endp.offset(1); rc = json_pointer_set_single_path(set, endp, value); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/response.txt similarity index 75% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/response.txt index 9365866102..bb36fedf07 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/ebb766ba26406ff7587a7b91d85dd70904eb01c7e539a460128aef1689c8d62b/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/104fe72e647aa270434942fa1266daa02a302705abe5758f768e456ebcb4c3c9/response.txt @@ -1,24 +1,23 @@ -```rust #[no_mangle] pub unsafe extern "C" fn json_pointer_setf( mut obj: *mut *mut json_object, mut value: *mut json_object, mut path_fmt: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { - let mut current_block: u64; + let mut c2rust_current_block: u64; let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut set: *mut json_object = ::core::ptr::null_mut::(); - let mut args_0: ::core::ffi::VaListImpl; + let mut args: ::core::ffi::VaListImpl; let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; if obj.is_null() || path_fmt.is_null() { *__errno_location() = EINVAL; - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } /* pass a working copy to the recursive call */ - args_0 = args.clone(); - rc = vasprintf(&raw mut path_copy, path_fmt, args_0.as_va_list()); + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); if rc < 0 as ::core::ffi::c_int { return rc; } @@ -29,24 +28,24 @@ pub unsafe extern "C" fn json_pointer_setf( != '/' as i32 { *__errno_location() = EINVAL; - rc = -(1 as ::core::ffi::c_int); + rc = -1 as ::core::ffi::c_int; } else { /* If there's only 1 level to set, stop here */ endp = strrchr(path_copy, '/' as i32); if endp == path_copy { set = *obj; - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } else { *endp = '\0' as i32 as ::core::ffi::c_char; rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); if rc != 0 { - current_block = 4724740344109054664; + c2rust_current_block = 13203993160948060081; } else { - current_block = 11653677672931389417; + c2rust_current_block = 4597719165585933616; } } - match current_block { - 4724740344109054664 => {} + match c2rust_current_block { + 13203993160948060081 => {} _ => { endp = endp.offset(1); rc = json_pointer_set_single_path(set, endp, value); @@ -55,5 +54,4 @@ pub unsafe extern "C" fn json_pointer_setf( } free(path_copy as *mut ::core::ffi::c_void); return rc; -} -``` \ No newline at end of file +} \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/metadata.toml new file mode 100644 index 0000000000..0e73a8beff --- /dev/null +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/metadata.toml @@ -0,0 +1,182 @@ +transform = "CommentTransfer" +identifier = "json_pointer_setf" +model = "gemini-3-flash-preview" +response = """#[no_mangle] +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + /* pass a working copy to the recursive call */ + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + /* If there's only 1 level to set, stop here */ + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10922793456893533591; + } else { + *endp = '\\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13059762155071316373; + } else { + c2rust_current_block = 10922793456893533591; + } + } + match c2rust_current_block { + 13059762155071316373 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +}""" + +[[messages]] +role = "user" +content = """Transfer the comments from the following C function to the corresponding Rust function. +Do not add any comments that are not present in the C function. +Use Rust doc comment syntax (///) where appropriate (e.g., for function documentation). +Respond with the Rust function definition with the transferred comments; say nothing else. + +C function: +```c +int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...) +{ +\tchar *endp; +\tchar *path_copy = NULL; +\tstruct json_object *set = NULL; +\tva_list args; +\tint rc = 0; + +\tif (!obj || !path_fmt) { +\t\terrno = EINVAL; +\t\treturn -1; +\t} + +\t/* pass a working copy to the recursive call */ +\tva_start(args, path_fmt); +\trc = vasprintf(&path_copy, path_fmt, args); +\tva_end(args); + +\tif (rc < 0) +\t\treturn rc; + +\tif (path_copy[0] == '\\0') { +\t\tjson_object_put(*obj); +\t\t*obj = value; +\t\tgoto out; +\t} + +\tif (path_copy[0] != '/') { +\t\terrno = EINVAL; +\t\trc = -1; +\t\tgoto out; +\t} + +\t/* If there's only 1 level to set, stop here */ +\tif ((endp = strrchr(path_copy, '/')) == path_copy) { +\t\tset = *obj; +\t\tgoto set_single_path; +\t} + +\t*endp = '\\0'; +\trc = json_pointer_get_recursive(*obj, path_copy, &set); + +\tif (rc) +\t\tgoto out; + +set_single_path: +\tendp++; +\trc = json_pointer_set_single_path(set, endp, value); +out: +\tfree(path_copy); +\treturn rc; +}``` + +Rust function: +```rust +#[no_mangle] + +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10922793456893533591; + } else { + *endp = '\\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13059762155071316373; + } else { + c2rust_current_block = 10922793456893533591; + } + } + match c2rust_current_block { + 13059762155071316373 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +}``` +""" diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/response.txt new file mode 100644 index 0000000000..50878b8a2f --- /dev/null +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/1afe8dcc3f354fa2a93015be9d241f8d28dc0730ce338d5da2e408195b7600bc/response.txt @@ -0,0 +1,57 @@ +#[no_mangle] +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + /* pass a working copy to the recursive call */ + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + /* If there's only 1 level to set, stop here */ + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10922793456893533591; + } else { + *endp = '\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13059762155071316373; + } else { + c2rust_current_block = 10922793456893533591; + } + } + match c2rust_current_block { + 13059762155071316373 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +} \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/metadata.toml new file mode 100644 index 0000000000..c2df1a7c32 --- /dev/null +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/metadata.toml @@ -0,0 +1,185 @@ +transform = "CommentTransfer" +identifier = "json_pointer_setf" +model = "gemini-3-flash-preview" +response = """```rust +#[no_mangle] + +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + // pass a working copy to the recursive call + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + // If there's only 1 level to set, stop here + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10838823251511014062; + } else { + *endp = '\\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13656143724778538616; + } else { + c2rust_current_block = 10838823251511014062; + } + } + match c2rust_current_block { + 13656143724778538616 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +} +```""" + +[[messages]] +role = "user" +content = """Transfer the comments from the following C function to the corresponding Rust function. +Do not add any comments that are not present in the C function. +Use Rust doc comment syntax (///) where appropriate (e.g., for function documentation). +Respond with the Rust function definition with the transferred comments; say nothing else. + +C function: +```c +int json_pointer_setf(struct json_object **obj, struct json_object *value, const char *path_fmt, ...) +{ +\tchar *endp; +\tchar *path_copy = NULL; +\tstruct json_object *set = NULL; +\tva_list args; +\tint rc = 0; + +\tif (!obj || !path_fmt) { +\t\terrno = EINVAL; +\t\treturn -1; +\t} + +\t/* pass a working copy to the recursive call */ +\tva_start(args, path_fmt); +\trc = vasprintf(&path_copy, path_fmt, args); +\tva_end(args); + +\tif (rc < 0) +\t\treturn rc; + +\tif (path_copy[0] == '\\0') { +\t\tjson_object_put(*obj); +\t\t*obj = value; +\t\tgoto out; +\t} + +\tif (path_copy[0] != '/') { +\t\terrno = EINVAL; +\t\trc = -1; +\t\tgoto out; +\t} + +\t/* If there's only 1 level to set, stop here */ +\tif ((endp = strrchr(path_copy, '/')) == path_copy) { +\t\tset = *obj; +\t\tgoto set_single_path; +\t} + +\t*endp = '\\0'; +\trc = json_pointer_get_recursive(*obj, path_copy, &set); + +\tif (rc) +\t\tgoto out; + +set_single_path: +\tendp++; +\trc = json_pointer_set_single_path(set, endp, value); +out: +\tfree(path_copy); +\treturn rc; +}``` + +Rust function: +```rust +#[no_mangle] + +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10838823251511014062; + } else { + *endp = '\\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13656143724778538616; + } else { + c2rust_current_block = 10838823251511014062; + } + } + match c2rust_current_block { + 13656143724778538616 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +}``` +""" diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/response.txt new file mode 100644 index 0000000000..134812a916 --- /dev/null +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/json_pointer_setf/d4be0c5b80316002344524cc1478e6a9a4aa3710b1decd880026933769dc790d/response.txt @@ -0,0 +1,60 @@ +```rust +#[no_mangle] + +pub unsafe extern "C" fn json_pointer_setf( + mut obj: *mut *mut json_object, + mut value: *mut json_object, + mut path_fmt: *const ::core::ffi::c_char, + mut c2rust_args: ... +) -> ::core::ffi::c_int { + let mut c2rust_current_block: u64; + let mut endp: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut path_copy: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); + let mut set: *mut json_object = ::core::ptr::null_mut::(); + let mut args: ::core::ffi::VaListImpl; + let mut rc: ::core::ffi::c_int = 0 as ::core::ffi::c_int; + if obj.is_null() || path_fmt.is_null() { + *__errno_location() = EINVAL; + return -1 as ::core::ffi::c_int; + } + // pass a working copy to the recursive call + args = c2rust_args.clone(); + rc = vasprintf(&raw mut path_copy, path_fmt, args.as_va_list()); + if rc < 0 as ::core::ffi::c_int { + return rc; + } + if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int == '\0' as i32 { + json_object_put(*obj); + *obj = value; + } else if *path_copy.offset(0 as ::core::ffi::c_int as isize) as ::core::ffi::c_int + != '/' as i32 + { + *__errno_location() = EINVAL; + rc = -1 as ::core::ffi::c_int; + } else { + // If there's only 1 level to set, stop here + endp = strrchr(path_copy, '/' as i32); + if endp == path_copy { + set = *obj; + c2rust_current_block = 10838823251511014062; + } else { + *endp = '\0' as i32 as ::core::ffi::c_char; + rc = json_pointer_get_recursive(*obj, path_copy, &raw mut set); + if rc != 0 { + c2rust_current_block = 13656143724778538616; + } else { + c2rust_current_block = 10838823251511014062; + } + } + match c2rust_current_block { + 13656143724778538616 => {} + _ => { + endp = endp.offset(1); + rc = json_pointer_set_single_path(set, endp, value); + } + } + } + free(path_copy as *mut ::core::ffi::c_void); + return rc; +} +``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/metadata.toml similarity index 79% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/metadata.toml index f921b3f862..a430f07f23 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/metadata.toml @@ -3,20 +3,22 @@ identifier = "lh_char_hash" model = "gemini-3-flash-preview" response = """```rust unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core::ffi::c_ulong { - static mut random_seed: ::core::ffi::c_int = -(1 as ::core::ffi::c_int); - if random_seed == -(1 as ::core::ffi::c_int) { + static mut random_seed: ::core::ffi::c_int = -1 as ::core::ffi::c_int; + if ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) + == -1 as ::core::ffi::c_int + { let mut seed: ::core::ffi::c_int = 0; /* we can't use -1 as it is the unitialized sentinel */ loop { seed = json_c_get_random_seed(); - if !(seed == -(1 as ::core::ffi::c_int)) { + if !(seed == -1 as ::core::ffi::c_int) { break; } } //#warning "racy random seed initializtion if used by multiple threads" ::core::intrinsics::atomic_cxchg_seqcst_seqcst( &raw mut random_seed, - -(1 as ::core::ffi::c_int), + -1 as ::core::ffi::c_int, seed, ) .0; /* potentially racy */ @@ -24,7 +26,7 @@ unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core:: return hashlittle( k as *const ::core::ffi::c_char as *const ::core::ffi::c_void, strlen(k as *const ::core::ffi::c_char), - random_seed as uint32_t, + ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) as uint32_t, ) as ::core::ffi::c_ulong; } ```""" @@ -76,18 +78,20 @@ static unsigned long lh_char_hash(const void *k) Rust function: ```rust unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core::ffi::c_ulong { - static mut random_seed: ::core::ffi::c_int = -(1 as ::core::ffi::c_int); - if random_seed == -(1 as ::core::ffi::c_int) { + static mut random_seed: ::core::ffi::c_int = -1 as ::core::ffi::c_int; + if ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) + == -1 as ::core::ffi::c_int + { let mut seed: ::core::ffi::c_int = 0; loop { seed = json_c_get_random_seed(); - if !(seed == -(1 as ::core::ffi::c_int)) { + if !(seed == -1 as ::core::ffi::c_int) { break; } } ::core::intrinsics::atomic_cxchg_seqcst_seqcst( &raw mut random_seed, - -(1 as ::core::ffi::c_int), + -1 as ::core::ffi::c_int, seed, ) .0; @@ -95,7 +99,7 @@ unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core:: return hashlittle( k as *const ::core::ffi::c_char as *const ::core::ffi::c_void, strlen(k as *const ::core::ffi::c_char), - random_seed as uint32_t, + ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) as uint32_t, ) as ::core::ffi::c_ulong; }``` """ diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/response.txt similarity index 65% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/response.txt index f2f1e89139..85d4086d58 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/cbb02500330fcd0516eb8e142662c080ba0bce337470f998719a43a71fe8d2f7/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_char_hash/8e4847699488c36bdccf3aa97c779d49ab67710ebbef0698286e5663df08b3c7/response.txt @@ -1,19 +1,21 @@ ```rust unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core::ffi::c_ulong { - static mut random_seed: ::core::ffi::c_int = -(1 as ::core::ffi::c_int); - if random_seed == -(1 as ::core::ffi::c_int) { + static mut random_seed: ::core::ffi::c_int = -1 as ::core::ffi::c_int; + if ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) + == -1 as ::core::ffi::c_int + { let mut seed: ::core::ffi::c_int = 0; /* we can't use -1 as it is the unitialized sentinel */ loop { seed = json_c_get_random_seed(); - if !(seed == -(1 as ::core::ffi::c_int)) { + if !(seed == -1 as ::core::ffi::c_int) { break; } } //#warning "racy random seed initializtion if used by multiple threads" ::core::intrinsics::atomic_cxchg_seqcst_seqcst( &raw mut random_seed, - -(1 as ::core::ffi::c_int), + -1 as ::core::ffi::c_int, seed, ) .0; /* potentially racy */ @@ -21,7 +23,7 @@ unsafe extern "C" fn lh_char_hash(mut k: *const ::core::ffi::c_void) -> ::core:: return hashlittle( k as *const ::core::ffi::c_char as *const ::core::ffi::c_void, strlen(k as *const ::core::ffi::c_char), - random_seed as uint32_t, + ::core::ptr::read_volatile::<::core::ffi::c_int>(&raw const random_seed) as uint32_t, ) as ::core::ffi::c_ulong; } ``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/metadata.toml similarity index 90% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/metadata.toml index f788a629d9..22d25c442e 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/metadata.toml @@ -9,11 +9,11 @@ unsafe extern "C" fn lh_perllike_str_hash( let mut rkey: *const ::core::ffi::c_char = k as *const ::core::ffi::c_char; let mut hashval: ::core::ffi::c_uint = 1 as ::core::ffi::c_uint; while *rkey != 0 { - let fresh0 = rkey; + let c2rust_fresh0 = rkey; rkey = rkey.offset(1); hashval = hashval .wrapping_mul(33 as ::core::ffi::c_uint) - .wrapping_add(*fresh0 as ::core::ffi::c_uint); + .wrapping_add(*c2rust_fresh0 as ::core::ffi::c_uint); } return hashval as ::core::ffi::c_ulong; }""" @@ -49,11 +49,11 @@ unsafe extern "C" fn lh_perllike_str_hash( let mut rkey: *const ::core::ffi::c_char = k as *const ::core::ffi::c_char; let mut hashval: ::core::ffi::c_uint = 1 as ::core::ffi::c_uint; while *rkey != 0 { - let fresh0 = rkey; + let c2rust_fresh0 = rkey; rkey = rkey.offset(1); hashval = hashval .wrapping_mul(33 as ::core::ffi::c_uint) - .wrapping_add(*fresh0 as ::core::ffi::c_uint); + .wrapping_add(*c2rust_fresh0 as ::core::ffi::c_uint); } return hashval as ::core::ffi::c_ulong; }``` diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/response.txt similarity index 85% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/response.txt index a15d5fba38..dd04cfec00 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/4246fa81c9325d9698903efc694b65daed222bfd2948cc3a9795104b08685b05/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_perllike_str_hash/a651b3e8f830698124810c17c505c302bfc1e5f8b59866b609fe797b81980731/response.txt @@ -6,11 +6,11 @@ unsafe extern "C" fn lh_perllike_str_hash( let mut rkey: *const ::core::ffi::c_char = k as *const ::core::ffi::c_char; let mut hashval: ::core::ffi::c_uint = 1 as ::core::ffi::c_uint; while *rkey != 0 { - let fresh0 = rkey; + let c2rust_fresh0 = rkey; rkey = rkey.offset(1); hashval = hashval .wrapping_mul(33 as ::core::ffi::c_uint) - .wrapping_add(*fresh0 as ::core::ffi::c_uint); + .wrapping_add(*c2rust_fresh0 as ::core::ffi::c_uint); } return hashval as ::core::ffi::c_ulong; } \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/metadata.toml similarity index 71% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/metadata.toml index e4cbf4c154..98b6f95a38 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/metadata.toml @@ -11,21 +11,21 @@ pub unsafe extern "C" fn lh_table_delete_entry( /* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */ if n < 0 as ptrdiff_t { - return -(2 as ::core::ffi::c_int); + return -2 as ::core::ffi::c_int; } if (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_EMPTY as *const ::core::ffi::c_void || (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_FREED as *const ::core::ffi::c_void { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*t).count -= 1; if (*t).free_fn.is_some() { (*t).free_fn.expect("non-null function pointer")(e); } - let ref mut fresh8 = (*(*t).table.offset(n as isize)).v; - *fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); - let ref mut fresh9 = (*(*t).table.offset(n as isize)).k; - *fresh9 = crate::src::linkhash::LH_FREED; + let ref mut c2rust_fresh8 = (*(*t).table.offset(n as isize)).v; + *c2rust_fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); + let ref mut c2rust_fresh9 = (*(*t).table.offset(n as isize)).k; + *c2rust_fresh9 = crate::src::linkhash::LH_FREED; if (*t).tail == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry && (*t).head == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry { @@ -38,15 +38,15 @@ pub unsafe extern "C" fn lh_table_delete_entry( (*(*(*t).tail).prev).next = ::core::ptr::null_mut::(); (*t).tail = (*(*t).tail).prev; } else { - let ref mut fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; - *fresh10 = (*(*t).table.offset(n as isize)).next; - let ref mut fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; - *fresh11 = (*(*t).table.offset(n as isize)).prev; + let ref mut c2rust_fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; + *c2rust_fresh10 = (*(*t).table.offset(n as isize)).next; + let ref mut c2rust_fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; + *c2rust_fresh11 = (*(*t).table.offset(n as isize)).prev; } - let ref mut fresh12 = (*(*t).table.offset(n as isize)).prev; - *fresh12 = ::core::ptr::null_mut::(); - let ref mut fresh13 = (*(*t).table.offset(n as isize)).next; - *fresh13 = *fresh12; + let ref mut c2rust_fresh12 = (*(*t).table.offset(n as isize)).prev; + *c2rust_fresh12 = ::core::ptr::null_mut::(); + let ref mut c2rust_fresh13 = (*(*t).table.offset(n as isize)).next; + *c2rust_fresh13 = *c2rust_fresh12; return 0 as ::core::ffi::c_int; } ```""" @@ -98,21 +98,21 @@ pub unsafe extern "C" fn lh_table_delete_entry( ) -> ::core::ffi::c_int { let mut n: ptrdiff_t = e.offset_from((*t).table) as ::core::ffi::c_long as ptrdiff_t; if n < 0 as ptrdiff_t { - return -(2 as ::core::ffi::c_int); + return -2 as ::core::ffi::c_int; } if (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_EMPTY as *const ::core::ffi::c_void || (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_FREED as *const ::core::ffi::c_void { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*t).count -= 1; if (*t).free_fn.is_some() { (*t).free_fn.expect("non-null function pointer")(e); } - let ref mut fresh8 = (*(*t).table.offset(n as isize)).v; - *fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); - let ref mut fresh9 = (*(*t).table.offset(n as isize)).k; - *fresh9 = crate::src::linkhash::LH_FREED; + let ref mut c2rust_fresh8 = (*(*t).table.offset(n as isize)).v; + *c2rust_fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); + let ref mut c2rust_fresh9 = (*(*t).table.offset(n as isize)).k; + *c2rust_fresh9 = crate::src::linkhash::LH_FREED; if (*t).tail == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry && (*t).head == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry { @@ -125,15 +125,15 @@ pub unsafe extern "C" fn lh_table_delete_entry( (*(*(*t).tail).prev).next = ::core::ptr::null_mut::(); (*t).tail = (*(*t).tail).prev; } else { - let ref mut fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; - *fresh10 = (*(*t).table.offset(n as isize)).next; - let ref mut fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; - *fresh11 = (*(*t).table.offset(n as isize)).prev; + let ref mut c2rust_fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; + *c2rust_fresh10 = (*(*t).table.offset(n as isize)).next; + let ref mut c2rust_fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; + *c2rust_fresh11 = (*(*t).table.offset(n as isize)).prev; } - let ref mut fresh12 = (*(*t).table.offset(n as isize)).prev; - *fresh12 = ::core::ptr::null_mut::(); - let ref mut fresh13 = (*(*t).table.offset(n as isize)).next; - *fresh13 = *fresh12; + let ref mut c2rust_fresh12 = (*(*t).table.offset(n as isize)).prev; + *c2rust_fresh12 = ::core::ptr::null_mut::(); + let ref mut c2rust_fresh13 = (*(*t).table.offset(n as isize)).next; + *c2rust_fresh13 = *c2rust_fresh12; return 0 as ::core::ffi::c_int; }``` """ diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/response.txt similarity index 64% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/response.txt index 36299269ee..b2a5b9f5d9 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/a46322d305987677cd7babf57328141076150b73b6b5efed1fc00d190d1c89c4/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/lh_table_delete_entry/71e5f1a3a3711d1d48822dd2cf2b1093890d8d25f2920cbaed5552185bb975da/response.txt @@ -8,21 +8,21 @@ pub unsafe extern "C" fn lh_table_delete_entry( /* CAW: this is bad, really bad, maybe stack goes other direction on this machine... */ if n < 0 as ptrdiff_t { - return -(2 as ::core::ffi::c_int); + return -2 as ::core::ffi::c_int; } if (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_EMPTY as *const ::core::ffi::c_void || (*(*t).table.offset(n as isize)).k == crate::src::linkhash::LH_FREED as *const ::core::ffi::c_void { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } (*t).count -= 1; if (*t).free_fn.is_some() { (*t).free_fn.expect("non-null function pointer")(e); } - let ref mut fresh8 = (*(*t).table.offset(n as isize)).v; - *fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); - let ref mut fresh9 = (*(*t).table.offset(n as isize)).k; - *fresh9 = crate::src::linkhash::LH_FREED; + let ref mut c2rust_fresh8 = (*(*t).table.offset(n as isize)).v; + *c2rust_fresh8 = ::core::ptr::null::<::core::ffi::c_void>(); + let ref mut c2rust_fresh9 = (*(*t).table.offset(n as isize)).k; + *c2rust_fresh9 = crate::src::linkhash::LH_FREED; if (*t).tail == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry && (*t).head == (*t).table.offset(n as isize) as *mut crate::src::linkhash::lh_entry { @@ -35,15 +35,15 @@ pub unsafe extern "C" fn lh_table_delete_entry( (*(*(*t).tail).prev).next = ::core::ptr::null_mut::(); (*t).tail = (*(*t).tail).prev; } else { - let ref mut fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; - *fresh10 = (*(*t).table.offset(n as isize)).next; - let ref mut fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; - *fresh11 = (*(*t).table.offset(n as isize)).prev; + let ref mut c2rust_fresh10 = (*(*(*t).table.offset(n as isize)).prev).next; + *c2rust_fresh10 = (*(*t).table.offset(n as isize)).next; + let ref mut c2rust_fresh11 = (*(*(*t).table.offset(n as isize)).next).prev; + *c2rust_fresh11 = (*(*t).table.offset(n as isize)).prev; } - let ref mut fresh12 = (*(*t).table.offset(n as isize)).prev; - *fresh12 = ::core::ptr::null_mut::(); - let ref mut fresh13 = (*(*t).table.offset(n as isize)).next; - *fresh13 = *fresh12; + let ref mut c2rust_fresh12 = (*(*t).table.offset(n as isize)).prev; + *c2rust_fresh12 = ::core::ptr::null_mut::(); + let ref mut c2rust_fresh13 = (*(*t).table.offset(n as isize)).next; + *c2rust_fresh13 = *c2rust_fresh12; return 0 as ::core::ffi::c_int; } ``` \ No newline at end of file diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/metadata.toml b/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/metadata.toml similarity index 87% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/metadata.toml rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/metadata.toml index 293d69f6ed..cd8c191577 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/metadata.toml +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/metadata.toml @@ -1,18 +1,19 @@ transform = "CommentTransfer" identifier = "sprintbuf" model = "gemini-3-flash-preview" -response = """#[no_mangle] +response = """```rust +#[no_mangle] pub unsafe extern "C" fn sprintbuf( mut p: *mut crate::src::printbuf::printbuf, mut msg: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { let mut ap: ::core::ffi::VaListImpl; let mut t: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut size: ::core::ffi::c_int = 0; let mut buf: [::core::ffi::c_char; 128] = [0; 128]; /* user stack buffer first */ - ap = args.clone(); + ap = c2rust_args.clone(); size = vsnprintf( &raw mut buf as *mut ::core::ffi::c_char, 128 as size_t, @@ -23,11 +24,11 @@ pub unsafe extern "C" fn sprintbuf( with vasprintf. Note: some implementation of vsnprintf return -1 if output is truncated whereas some return the number of bytes that would have been written - this code handles both cases. */ - if size == -(1 as ::core::ffi::c_int) || size > 127 as ::core::ffi::c_int { - ap = args.clone(); + if size == -1 as ::core::ffi::c_int || size > 127 as ::core::ffi::c_int { + ap = c2rust_args.clone(); size = vasprintf(&raw mut t, msg, ap.as_va_list()); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } printbuf_memappend(p, t, size); free(t as *mut ::core::ffi::c_void); @@ -36,7 +37,8 @@ pub unsafe extern "C" fn sprintbuf( printbuf_memappend(p, &raw mut buf as *mut ::core::ffi::c_char, size); return size; }; -}""" +} +```""" [[messages]] role = "user" @@ -82,24 +84,24 @@ Rust function: pub unsafe extern "C" fn sprintbuf( mut p: *mut crate::src::printbuf::printbuf, mut msg: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { let mut ap: ::core::ffi::VaListImpl; let mut t: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut size: ::core::ffi::c_int = 0; let mut buf: [::core::ffi::c_char; 128] = [0; 128]; - ap = args.clone(); + ap = c2rust_args.clone(); size = vsnprintf( &raw mut buf as *mut ::core::ffi::c_char, 128 as size_t, msg, ap.as_va_list(), ); - if size == -(1 as ::core::ffi::c_int) || size > 127 as ::core::ffi::c_int { - ap = args.clone(); + if size == -1 as ::core::ffi::c_int || size > 127 as ::core::ffi::c_int { + ap = c2rust_args.clone(); size = vasprintf(&raw mut t, msg, ap.as_va_list()); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } printbuf_memappend(p, t, size); free(t as *mut ::core::ffi::c_void); diff --git a/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/response.txt b/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/response.txt similarity index 84% rename from c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/response.txt rename to c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/response.txt index 916698a08f..dda1cadc6a 100644 --- a/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/61141d171a3fd3aa6aa5d73a8168234378f11d3b4c37592ebe9e28c4c9566586/response.txt +++ b/c2rust-postprocess/tests/llm-cache/CommentTransfer/sprintbuf/d584ecff8e06d4cff4612a9fb4b8d012b0062d2f9413a266b988ca85ed63c5b7/response.txt @@ -1,15 +1,16 @@ +```rust #[no_mangle] pub unsafe extern "C" fn sprintbuf( mut p: *mut crate::src::printbuf::printbuf, mut msg: *const ::core::ffi::c_char, - mut args: ... + mut c2rust_args: ... ) -> ::core::ffi::c_int { let mut ap: ::core::ffi::VaListImpl; let mut t: *mut ::core::ffi::c_char = ::core::ptr::null_mut::<::core::ffi::c_char>(); let mut size: ::core::ffi::c_int = 0; let mut buf: [::core::ffi::c_char; 128] = [0; 128]; /* user stack buffer first */ - ap = args.clone(); + ap = c2rust_args.clone(); size = vsnprintf( &raw mut buf as *mut ::core::ffi::c_char, 128 as size_t, @@ -20,11 +21,11 @@ pub unsafe extern "C" fn sprintbuf( with vasprintf. Note: some implementation of vsnprintf return -1 if output is truncated whereas some return the number of bytes that would have been written - this code handles both cases. */ - if size == -(1 as ::core::ffi::c_int) || size > 127 as ::core::ffi::c_int { - ap = args.clone(); + if size == -1 as ::core::ffi::c_int || size > 127 as ::core::ffi::c_int { + ap = c2rust_args.clone(); size = vasprintf(&raw mut t, msg, ap.as_va_list()); if size < 0 as ::core::ffi::c_int { - return -(1 as ::core::ffi::c_int); + return -1 as ::core::ffi::c_int; } printbuf_memappend(p, t, size); free(t as *mut ::core::ffi::c_void); @@ -33,4 +34,5 @@ pub unsafe extern "C" fn sprintbuf( printbuf_memappend(p, &raw mut buf as *mut ::core::ffi::c_char, size); return size; }; -} \ No newline at end of file +} +``` \ No newline at end of file diff --git a/tests/integration/tests/__init__.py b/tests/integration/tests/__init__.py index 3e1f361141..b00de1ff15 100644 --- a/tests/integration/tests/__init__.py +++ b/tests/integration/tests/__init__.py @@ -6,7 +6,6 @@ import sys import subprocess from time import perf_counter -from typing import List # , Set, Dict, Tuple, Optional from tests.util import * from tests.requirements import * @@ -23,6 +22,9 @@ class Test(object): "refactor": ["refactor.gen.sh", "refactor.sh"], "cargo.refactor": ["cargo.refactor.gen.sh", "cargo.refactor.sh"], "check.refactor": ["check.refactor.sh", "test.sh"], + "postprocess": ["postprocess.gen.sh", "postprocess.sh"], + "cargo.postprocess": ["cargo.postprocess.gen.sh", "cargo.postprocess.sh"], + "check.postprocess": ["check.postprocess.sh", "test.sh"], } def __init__(self, directory: Path, generated_scripts: set[Path]): diff --git a/tests/integration/tests/conf.yml b/tests/integration/tests/conf.yml index 6c6401edb9..ef579a5240 100644 --- a/tests/integration/tests/conf.yml +++ b/tests/integration/tests/conf.yml @@ -12,6 +12,7 @@ requirements: - c2rust - c2rust-transpile - c2rust-refactor + - c2rust-postprocess - make - cmake - cargo diff --git a/tests/integration/tests/json-c/conf.yml b/tests/integration/tests/json-c/conf.yml index e34b0a02c8..2d85e22861 100644 --- a/tests/integration/tests/json-c/conf.yml +++ b/tests/integration/tests/json-c/conf.yml @@ -22,3 +22,9 @@ refactor: cargo.refactor: autogen: true + +postprocess: + autogen: true + +cargo.postprocess: + autogen: true diff --git a/tests/integration/tests/templates.py b/tests/integration/tests/templates.py index 760b0ecea5..3dd85aa1e8 100644 --- a/tests/integration/tests/templates.py +++ b/tests/integration/tests/templates.py @@ -1,10 +1,11 @@ import os from pathlib import Path +import shlex import stat from collections.abc import Mapping from typing import Any, Generator -from tests.util import * +from tests.util import Config from jinja2 import Template TRANSPILE_SH: str = r"""#!/usr/bin/env bash @@ -78,6 +79,18 @@ C2RUST_TRANSFORMS """ +POSTPROCESS_SH: str = r"""#!/usr/bin/env bash +# this file was autogenerated by templates.py +set -e; set -o pipefail + +SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)" +LOG_FILE="$SCRIPT_DIR/$(basename "$0")".log + +cd "${SCRIPT_DIR}" + +c2rust-postprocess --update-rust {{args}} repo/lib.rs 2>&1 | tee "$LOG_FILE" +""" + CARGO_SH: str = r"""#!/usr/bin/env bash # this file was autogenerated by templates.py set -e; set -o pipefail @@ -92,7 +105,7 @@ """ -def render_script(template: str, out_path: str, params: dict): +def render_script(template: str, out_path: str | Path, params: dict): out = Template(template).render(**params) with open(out_path, "w") as fh: @@ -108,11 +121,11 @@ def autogen_transpile(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, transpile = yaml.get("transpile") if not (transpile and isinstance(transpile, dict)): return - + ag = transpile.get("autogen") if not (ag and isinstance(ag, bool)): return - + params = {"binary": "--emit-build-files", "cflags": ""} binary = transpile.get("binary") @@ -144,19 +157,17 @@ def autogen_refactor(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, N refactor = yaml.get("refactor") if not (refactor and isinstance(refactor, dict)): return - + ag = refactor.get("autogen") if not (ag and isinstance(ag, bool)): return - + params = {"transform_lines": ""} # Get list of transformations from config transforms = refactor.get("transforms") if transforms and isinstance(transforms, list): - lines = [ - t.strip() for t in transforms if isinstance(t, str) and t.strip() - ] + lines = [t.strip() for t in transforms if isinstance(t, str) and t.strip()] if lines: params["transform_lines"] = "\n".join(lines) elif transforms and isinstance(transforms, str): @@ -171,6 +182,40 @@ def autogen_refactor(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, N yield Path(out_path) +def autogen_postprocess( + conf: str, yaml: dict[str, Any], verbose: bool +) -> Generator[Path, None, None]: + """ + Yield generated paths. + """ + + conf = Path(conf) + + postprocess = yaml.get("postprocess") + if not (postprocess and isinstance(postprocess, dict)): + return + + ag = postprocess.get("autogen") + if not (ag and isinstance(ag, bool)): + return + + params = {"args": ""} + + exclude_file = conf.with_name("postprocess-exclude.yml") + if exclude_file.exists(): + # args are relative to script dir + params["args"] = shlex.join( + ["--exclude-file", str(exclude_file.relative_to(conf.parent))] + ) + + if verbose: + params["args"] = f"--log-level DEBUG {params['args']}".rstrip() + + out_path = conf.with_name("postprocess.gen.sh") + render_script(POSTPROCESS_SH, out_path, params) + yield out_path + + def autogen_cargo(conf: str, yaml: dict[str, Any]) -> Generator[Path, None, None]: """ Yield generated paths. @@ -217,4 +262,5 @@ def autogen(conf: Config) -> Generator[Path, None, None]: for cf, yaml in conf.project_conf.items(): yield from autogen_transpile(cf, yaml) yield from autogen_refactor(cf, yaml) + yield from autogen_postprocess(cf, yaml, conf.verbose) yield from autogen_cargo(cf, yaml)