Fix fs::file log formatting

This commit is contained in:
Megamouse 2024-12-23 02:06:49 +01:00
parent 99044ce6c6
commit 53817dcc90
7 changed files with 32 additions and 39 deletions

View File

@ -273,7 +273,7 @@ error_code cellGifDecReadHeader(vm::ptr<GifDecoder> mainHandle, vm::ptr<GifStrea
return CELL_GIFDEC_ERROR_ARG; return CELL_GIFDEC_ERROR_ARG;
} }
const u32& fd = subHandle->fd; const u32 fd = subHandle->fd;
CellGifDecInfo& current_info = subHandle->info; CellGifDecInfo& current_info = subHandle->info;
// Write the header to buffer // Write the header to buffer
@ -302,7 +302,7 @@ error_code cellGifDecReadHeader(vm::ptr<GifDecoder> mainHandle, vm::ptr<GifStrea
return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss return CELL_GIFDEC_ERROR_STREAM_FORMAT; // Surprisingly there is no error code related with headerss
} }
u8 packedField = buffer[10]; const u8 packedField = buffer[10];
current_info.SWidth = buffer[6] + buffer[7] * 0x100; current_info.SWidth = buffer[6] + buffer[7] * 0x100;
current_info.SHeight = buffer[8] + buffer[9] * 0x100; current_info.SHeight = buffer[8] + buffer[9] * 0x100;
current_info.SGlobalColorTableFlag = packedField >> 7; current_info.SGlobalColorTableFlag = packedField >> 7;
@ -520,8 +520,8 @@ error_code cellGifDecDecodeData(vm::ptr<GifDecoder> mainHandle, vm::cptr<GifStre
return CELL_GIFDEC_ERROR_STREAM_FORMAT; return CELL_GIFDEC_ERROR_STREAM_FORMAT;
const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine); const int bytesPerLine = static_cast<int>(dataCtrlParam->outputBytesPerLine);
const char nComponents = 4; constexpr char nComponents = 4;
uint image_size = width * height * nComponents; const u32 image_size = width * height * nComponents;
switch(current_outParam.outputColorSpace) switch(current_outParam.outputColorSpace)
{ {
@ -541,9 +541,8 @@ error_code cellGifDecDecodeData(vm::ptr<GifDecoder> mainHandle, vm::cptr<GifStre
{ {
memcpy(data.get_ptr(), image.get(), image_size); memcpy(data.get_ptr(), image.get(), image_size);
} }
break;
} }
break;
case CELL_GIFDEC_ARGB: case CELL_GIFDEC_ARGB:
{ {
if (bytesPerLine > width * nComponents) // Check if we need padding if (bytesPerLine > width * nComponents) // Check if we need padding
@ -579,9 +578,8 @@ error_code cellGifDecDecodeData(vm::ptr<GifDecoder> mainHandle, vm::cptr<GifStre
} }
std::memcpy(data.get_ptr(), img.get(), image_size); std::memcpy(data.get_ptr(), img.get(), image_size);
} }
break;
} }
break;
default: default:
return CELL_GIFDEC_ERROR_ARG; return CELL_GIFDEC_ERROR_ARG;
} }

View File

@ -516,7 +516,7 @@ error_code cellHttpUtilEscapeUri(vm::ptr<char> out, u32 outSize, vm::cptr<u8> in
for (u32 pos = 0; rindex >= 0; rindex--, pos++) for (u32 pos = 0; rindex >= 0; rindex--, pos++)
{ {
char c1 = in[pos]; const char c1 = in[pos];
if (false) // DAT[c1] == '\x03') // TODO if (false) // DAT[c1] == '\x03') // TODO
{ {
@ -529,7 +529,7 @@ error_code cellHttpUtilEscapeUri(vm::ptr<char> out, u32 outSize, vm::cptr<u8> in
return CELL_HTTP_UTIL_ERROR_NO_MEMORY; return CELL_HTTP_UTIL_ERROR_NO_MEMORY;
} }
const char* chars = "0123456789ABCDEF"; constexpr const char* chars = "0123456789ABCDEF";
out[out_pos++] = '%'; // 0x25 out[out_pos++] = '%'; // 0x25
out[out_pos++] = chars[c1 >> 4]; out[out_pos++] = chars[c1 >> 4];
out[out_pos++] = chars[c1 & 0xf]; out[out_pos++] = chars[c1 & 0xf];
@ -618,7 +618,7 @@ error_code cellHttpUtilFormUrlEncode(vm::ptr<char> out, u32 outSize, vm::cptr<u8
for (u32 pos = 0; rindex >= 0; rindex--, pos++) for (u32 pos = 0; rindex >= 0; rindex--, pos++)
{ {
char c1 = in[pos]; const char c1 = in[pos];
if (c1 == ' ') if (c1 == ' ')
{ {
@ -645,7 +645,7 @@ error_code cellHttpUtilFormUrlEncode(vm::ptr<char> out, u32 outSize, vm::cptr<u8
return CELL_HTTP_UTIL_ERROR_NO_MEMORY; return CELL_HTTP_UTIL_ERROR_NO_MEMORY;
} }
const char* chars = "0123456789ABCDEF"; constexpr const char* chars = "0123456789ABCDEF";
out[out_pos++] = '%'; // 0x25 out[out_pos++] = '%'; // 0x25
out[out_pos++] = chars[c1 >> 4]; out[out_pos++] = chars[c1 >> 4];
out[out_pos++] = chars[c1 & 0xf]; out[out_pos++] = chars[c1 & 0xf];
@ -707,7 +707,7 @@ error_code cellHttpUtilFormUrlDecode(vm::ptr<u8> out, u32 size, vm::cptr<char> i
for (s32 index = 0, pos = 0;; index++) for (s32 index = 0, pos = 0;; index++)
{ {
size_needed = index + 1; size_needed = index + 1;
char c1 = in[pos++]; const char c1 = in[pos++];
if (!c1) if (!c1)
{ {
@ -731,7 +731,7 @@ error_code cellHttpUtilFormUrlDecode(vm::ptr<u8> out, u32 size, vm::cptr<char> i
const auto check_char = [](b8 c) const auto check_char = [](b8 c)
{ {
u32 utmp = static_cast<u32>(c); const u32 utmp = static_cast<u32>(c);
s32 stmp = utmp - 48; s32 stmp = utmp - 48;
if (static_cast<u8>(c - 48) > 9) if (static_cast<u8>(c - 48) > 9)
{ {

View File

@ -76,7 +76,7 @@ error_code cellJpgDecOpen(u32 mainHandle, vm::ptr<u32> subHandle, vm::ptr<CellJp
case CELL_JPGDEC_FILE: case CELL_JPGDEC_FILE:
{ {
// Get file descriptor and size // Get file descriptor and size
const auto real_path = vfs::get(src->fileName.get_ptr()); const std::string real_path = vfs::get(src->fileName.get_ptr());
fs::file file_s(real_path); fs::file file_s(real_path);
if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE; if (!file_s) return CELL_JPGDEC_ERROR_OPEN_FILE;
@ -127,8 +127,8 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
return CELL_JPGDEC_ERROR_FATAL; return CELL_JPGDEC_ERROR_FATAL;
} }
const u32& fd = subHandle_data->fd; const u32 fd = subHandle_data->fd;
const u64& fileSize = subHandle_data->fileSize; const u64 fileSize = subHandle_data->fileSize;
CellJpgDecInfo& current_info = subHandle_data->info; CellJpgDecInfo& current_info = subHandle_data->info;
// Write the header to buffer // Write the header to buffer
@ -158,12 +158,12 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
u32 i = 4; u32 i = 4;
if(i >= fileSize) if (i >= fileSize)
return CELL_JPGDEC_ERROR_HEADER; return CELL_JPGDEC_ERROR_HEADER;
u16 block_length = buffer[i] * 0xFF + buffer[i+1]; u16 block_length = buffer[i] * 0xFF + buffer[i + 1];
while(true) while (true)
{ {
i += block_length; // Increase the file index to get to the next block i += block_length; // Increase the file index to get to the next block
if (i >= fileSize || // Check to protect against segmentation faults if (i >= fileSize || // Check to protect against segmentation faults
@ -172,15 +172,15 @@ error_code cellJpgDecReadHeader(u32 mainHandle, u32 subHandle, vm::ptr<CellJpgDe
return CELL_JPGDEC_ERROR_HEADER; return CELL_JPGDEC_ERROR_HEADER;
} }
if(buffer[i+1] == 0xC0) if (buffer[i + 1] == 0xC0)
break; // 0xFFC0 is the "Start of frame" marker which contains the file size break; // 0xFFC0 is the "Start of frame" marker which contains the file size
i += 2; // Skip the block marker i += 2; // Skip the block marker
block_length = buffer[i] * 0xFF + buffer[i+1]; // Go to the next block block_length = buffer[i] * 0xFF + buffer[i + 1]; // Go to the next block
} }
current_info.imageWidth = buffer[i+7]*0x100 + buffer[i+8]; current_info.imageWidth = buffer[i + 7] * 0x100 + buffer[i + 8];
current_info.imageHeight = buffer[i+5]*0x100 + buffer[i+6]; current_info.imageHeight = buffer[i + 5] * 0x100 + buffer[i + 6];
current_info.numComponents = 3; // Unimplemented current_info.numComponents = 3; // Unimplemented
current_info.colorSpace = CELL_JPG_RGB; current_info.colorSpace = CELL_JPG_RGB;
@ -267,12 +267,11 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data,
{ {
memcpy(data.get_ptr(), image.get(), image_size); memcpy(data.get_ptr(), image.get(), image_size);
} }
break;
} }
break;
case CELL_JPG_ARGB: case CELL_JPG_ARGB:
{ {
const int nComponents = 4; constexpr int nComponents = 4;
image_size *= nComponents; image_size *= nComponents;
if (bytesPerLine > width * nComponents || flip) //check if we need padding if (bytesPerLine > width * nComponents || flip) //check if we need padding
{ {
@ -307,16 +306,15 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data,
} }
std::memcpy(data.get_ptr(), img.get(), image_size); std::memcpy(data.get_ptr(), img.get(), image_size);
} }
break;
} }
break;
case CELL_JPG_GRAYSCALE: case CELL_JPG_GRAYSCALE:
case CELL_JPG_YCbCr: case CELL_JPG_YCbCr:
case CELL_JPG_UPSAMPLE_ONLY: case CELL_JPG_UPSAMPLE_ONLY:
case CELL_JPG_GRAYSCALE_TO_ALPHA_RGBA: case CELL_JPG_GRAYSCALE_TO_ALPHA_RGBA:
case CELL_JPG_GRAYSCALE_TO_ALPHA_ARGB: case CELL_JPG_GRAYSCALE_TO_ALPHA_ARGB:
cellJpgDec.error("cellJpgDecDecodeData: Unsupported color space (%d)", current_outParam.outputColorSpace); cellJpgDec.error("cellJpgDecDecodeData: Unsupported color space (%d)", current_outParam.outputColorSpace);
break; break;
default: default:
return CELL_JPGDEC_ERROR_ARG; return CELL_JPGDEC_ERROR_ARG;
@ -324,7 +322,7 @@ error_code cellJpgDecDecodeData(u32 mainHandle, u32 subHandle, vm::ptr<u8> data,
dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH; dataOutInfo->status = CELL_JPGDEC_DEC_STATUS_FINISH;
if(dataCtrlParam->outputBytesPerLine) if (dataCtrlParam->outputBytesPerLine)
dataOutInfo->outputLines = static_cast<u32>(image_size / dataCtrlParam->outputBytesPerLine); dataOutInfo->outputLines = static_cast<u32>(image_size / dataCtrlParam->outputBytesPerLine);
return CELL_OK; return CELL_OK;

View File

@ -60,7 +60,6 @@ CellError lv2_cond::on_id_create()
if (!mutex) if (!mutex)
{ {
_mutex = static_cast<shared_ptr<lv2_obj>>(ensure(idm::get_unlocked<lv2_obj, lv2_mutex>(mtx_id))); _mutex = static_cast<shared_ptr<lv2_obj>>(ensure(idm::get_unlocked<lv2_obj, lv2_mutex>(mtx_id)));
} }
// Defer function // Defer function

View File

@ -79,7 +79,7 @@ void fmt_class_string<lv2_file>::format(std::string& out, u64 arg)
const usz pos = file.file ? file.file.pos() : umax; const usz pos = file.file ? file.file.pos() : umax;
const usz size = file.file ? file.file.size() : umax; const usz size = file.file ? file.file.size() : umax;
fmt::append(out, u8"%s, “%s”, Mode: 0x%x, Flags: 0x%x, Pos/Size: %s/%s (0x%x/0x%x)", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size), pos, size); fmt::append(out, u8"%s, '%s', Mode: 0x%x, Flags: 0x%x, Pos/Size: %s/%s (0x%x/0x%x)", file.type, file.name.data(), file.mode, file.flags, get_size(pos), get_size(size), pos, size);
} }
template<> template<>
@ -87,7 +87,7 @@ void fmt_class_string<lv2_dir>::format(std::string& out, u64 arg)
{ {
const auto& dir = get_object(arg); const auto& dir = get_object(arg);
fmt::append(out, u8"Directory, “%s”, Entries: %u/%u", dir.name.data(), std::min<u64>(dir.pos, dir.entries.size()), dir.entries.size()); fmt::append(out, u8"Directory, '%s', Entries: %u/%u", dir.name.data(), std::min<u64>(dir.pos, dir.entries.size()), dir.entries.size());
} }
bool has_fs_write_rights(std::string_view vpath) bool has_fs_write_rights(std::string_view vpath)

View File

@ -559,10 +559,8 @@ class idm
place = object; place = object;
return object; return object;
} }
else
{ *key_ptr = {};
key_ptr->clear();
}
} }
return {}; return {};

View File

@ -55,7 +55,7 @@ namespace reports
// ID Size Description // ID Size Description
u8 magnetometer_x2{}; // 0x27 1- X-axis magnetometer u8 magnetometer_x2{}; // 0x27 1- X-axis magnetometer
u8 magnetometer_y{}; // 0x28 1+ Y-axis magnetometer u8 magnetometer_y{}; // 0x28 1+ Y-axis magnetometer
u8 magnetometer_yz{}; // 0x29 1 XZ-axis magnetometer u8 magnetometer_yz{}; // 0x29 1 YZ-axis magnetometer
u8 magnetometer_z{}; // 0x2A 1- Z-axis magnetometer u8 magnetometer_z{}; // 0x2A 1- Z-axis magnetometer
u8 timestamp_lower{}; // 0x2B 1 Timestamp (lower byte) u8 timestamp_lower{}; // 0x2B 1 Timestamp (lower byte)
std::array<u8, 5> ext_device_data{}; // 0x2C 5 External device data std::array<u8, 5> ext_device_data{}; // 0x2C 5 External device data