Some minor cleanups - use size_t for return value of strlen,

extensions don't need 256-char arrays, etc.
This commit is contained in:
libretroadmin 2023-08-15 14:54:13 +02:00
parent f34481c332
commit 1765d491d1
2 changed files with 37 additions and 37 deletions

View file

@ -527,7 +527,7 @@ static INLINE void write_quad6(SpriteVertex *pv,
for (;;)
{
const char *delim = strchr(msg, '\n');
NSUInteger msg_len = delim ? (unsigned)(delim - msg) : strlen(msg);
size_t msg_len = delim ? (unsigned)(delim - msg) : strlen(msg);
/* Draw the line */
[self _renderLine:msg
@ -604,7 +604,7 @@ static INLINE void write_quad6(SpriteVertex *pv,
@autoreleasepool
{
NSUInteger max_glyphs = strlen(msg);
size_t max_glyphs = strlen(msg);
if (drop_x || drop_y)
max_glyphs *= 2;
@ -792,9 +792,9 @@ font_renderer_t metal_raster_font = {
if (mode.width == 0 || mode.height == 0)
{
/* 0 indicates full screen, so we'll use the view's dimensions,
/* 0 indicates full screen, so we'll use the view's dimensions,
* which should already be full screen
* If this turns out to be the wrong assumption, we can use NSScreen
* If this turns out to be the wrong assumption, we can use NSScreen
* to query the dimensions */
CGSize size = view.frame.size;
mode.width = (unsigned int)size.width;
@ -997,11 +997,11 @@ font_renderer_t metal_raster_font = {
int msg_width =
font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f);
float font_size = settings->floats.video_font_size;
unsigned bgcolor_red
unsigned bgcolor_red
= settings->uints.video_msg_bgcolor_red;
unsigned bgcolor_green
= settings->uints.video_msg_bgcolor_green;
unsigned bgcolor_blue
unsigned bgcolor_blue
= settings->uints.video_msg_bgcolor_blue;
float bgcolor_opacity = settings->floats.video_msg_bgcolor_opacity;
float x = settings->floats.video_msg_pos_x;
@ -1374,7 +1374,7 @@ typedef struct MTLALIGN(16)
{simd_make_float3(l, t, 0), simd_make_float2(0, 0)},
{simd_make_float3(r, t, 0), simd_make_float2(1, 0)},
};
_frame = frame;
memcpy(_v, v, sizeof(_v));
}
@ -1717,7 +1717,7 @@ typedef struct MTLALIGN(16)
MTLPixelFormat fmt = SelectOptimalPixelFormat(glslang_format_to_metal(_engine.pass[i].semantics.format));
if ( (i != (_shader->passes - 1))
|| (width != _viewport->width)
|| (width != _viewport->width)
|| (height != _viewport->height)
|| fmt != MTLPixelFormatBGRA8Unorm)
{
@ -1800,8 +1800,8 @@ typedef struct MTLALIGN(16)
for (i = 0; i < shader->passes; source = &_engine.pass[i++].rt)
{
matrix_float4x4 *mvp = (i == shader->passes-1)
? &_context.uniforms->projectionMatrix
matrix_float4x4 *mvp = (i == shader->passes-1)
? &_context.uniforms->projectionMatrix
: &_engine.mvp;
/* clang-format off */
@ -2213,7 +2213,7 @@ static bool metal_ctx_get_metrics(
break;
case UIUserInterfaceIdiomPhone:
if (max_size >= 2208.0)
/* Larger iPhones: iPhone Plus, X, XR, XS, XS Max,
/* Larger iPhones: iPhone Plus, X, XR, XS, XS Max,
* 11, 12, 13, 14, etc */
dpi = 81 * scale;
else
@ -2416,7 +2416,7 @@ static uintptr_t metal_load_texture(void *video_data, void *data,
return (uintptr_t)(__bridge_retained void *)(t);
}
static void metal_unload_texture(void *data,
static void metal_unload_texture(void *data,
bool threaded, uintptr_t handle)
{
if (!handle)

View file

@ -1243,7 +1243,7 @@ MainWindow::MainWindow(QWidget *parent) :
qRegisterMetaType<QPointer<ThumbnailWidget> >("ThumbnailWidget");
qRegisterMetaType<retro_task_callback_t>("retro_task_callback_t");
/* Cancel all progress dialogs immediately since
/* Cancel all progress dialogs immediately since
* they show as soon as they're constructed. */
m_updateProgressDialog->cancel();
m_thumbnailDownloadProgressDialog->cancel();
@ -1873,7 +1873,7 @@ bool MainWindow::showMessageBox(QString msg, MessageBoxType msgType,
return true;
if (
msg_box->result() != QMessageBox::Ok
msg_box->result() != QMessageBox::Ok
&& msg_box->result() != QMessageBox::Yes)
return false;
@ -2027,7 +2027,7 @@ void MainWindow::onLaunchWithComboBoxIndexChanged(int)
{
int i;
QString core_info_txt;
QVector<QHash<QString, QString> >
QVector<QHash<QString, QString> >
infoList = getCoreInfo();
QVariantMap coreMap = m_launchWithComboBox->currentData(Qt::UserRole).value<QVariantMap>();
core_selection coreSelection = static_cast<core_selection>(coreMap.value("core_selection").toInt());
@ -2038,9 +2038,9 @@ void MainWindow::onLaunchWithComboBoxIndexChanged(int)
for (i = 0; i < infoList.count(); i++)
{
const QHash<QString, QString> &hash = infoList.at(i);
const QString &key =
const QString &key =
hash.value("html_key", hash.value("key"));
const QString &value =
const QString &value =
hash.value("html_value", hash.value("value"));
if (!key.isEmpty())
@ -2256,8 +2256,8 @@ QVector<QHash<QString, QString> > MainWindow::getCoreInfo()
/* Search for current core */
core_info_find(current_core_path_data, &core_info);
if ( currentCore["core_path"].isEmpty()
|| !core_info
if ( currentCore["core_path"].isEmpty()
|| !core_info
|| !core_info->has_info)
{
QHash<QString, QString> hash;
@ -2562,8 +2562,8 @@ void MainWindow::selectBrowserDir(QString path)
m_fileTableView->setRootIndex(proxyIndex);
else
{
/* the directory is filtered out. Remove the filter for a moment.
* FIXME: Find a way to not have to do this
/* the directory is filtered out. Remove the filter for a moment.
* FIXME: Find a way to not have to do this
* (not filtering dirs is one). */
m_proxyFileModel->setFilterRegExp(QRegExp());
m_fileTableView->setRootIndex(m_proxyFileModel->mapFromSource(sourceIndex));
@ -2660,7 +2660,7 @@ QHash<QString, QString> MainWindow::getSelectedCore()
coreHash["core_path"] = path_get(RARCH_PATH_CORE);
break;
case CORE_SELECTION_PLAYLIST_SAVED:
if ( contentHash.isEmpty()
if ( contentHash.isEmpty()
|| contentHash["core_path"].isEmpty())
break;
@ -2675,7 +2675,7 @@ QHash<QString, QString> MainWindow::getSelectedCore()
break;
plName = contentHash["pl_name"].isEmpty()
? contentHash["db_name"]
? contentHash["db_name"]
: contentHash["pl_name"];
if (plName.isEmpty())
@ -2840,7 +2840,7 @@ void MainWindow::loadContent(const QHash<QString, QString> &contentHash)
sizeof(content_db_name_full));
const char *ext = path_get_extension(content_db_name_full);
if ( string_is_empty(ext)
if ( string_is_empty(ext)
|| !string_is_equal_noncase(ext,
FILE_PATH_LPL_EXTENSION_NO_DOT))
strlcpy(
@ -3034,10 +3034,10 @@ void MainWindow::setCoreActions()
for (i = 0; i < m_launchWithComboBox->count(); i++)
{
QVariantMap map =
QVariantMap map =
m_launchWithComboBox->itemData(
i, Qt::UserRole).toMap();
QByteArray CorePathArray =
QByteArray CorePathArray =
map.value("core_path").toString().toUtf8();
const char *core_path_data = CorePathArray.constData();
@ -3155,17 +3155,17 @@ void MainWindow::onSearchLineEditEdited(const QString &text)
if (!found_hiragana && !found_katakana)
m_searchRegExp = QRegExp(text, Qt::CaseInsensitive);
else if (found_hiragana && !found_katakana)
m_searchRegExp = QRegExp(text + "|"
m_searchRegExp = QRegExp(text + "|"
+ QString::fromUcs4(textHiraToKata.constData(),
textHiraToKata.size()), Qt::CaseInsensitive);
else if (!found_hiragana && found_katakana)
m_searchRegExp = QRegExp(text + "|"
m_searchRegExp = QRegExp(text + "|"
+ QString::fromUcs4(textKataToHira.constData(),
textKataToHira.size()), Qt::CaseInsensitive);
else
m_searchRegExp = QRegExp(text + "|"
m_searchRegExp = QRegExp(text + "|"
+ QString::fromUcs4(textHiraToKata.constData(),
textHiraToKata.size()) + "|" +
textHiraToKata.size()) + "|" +
QString::fromUcs4(textKataToHira.constData(),
textKataToHira.size()), Qt::CaseInsensitive);
@ -3387,7 +3387,7 @@ void MainWindow::onCurrentItemChanged(const QHash<QString, QString> &hash)
m_thumbnailPixmap2 = new QPixmap(thumbnailsDir + "/" + THUMBNAIL_TITLE + "/" + thumbnailName);
m_thumbnailPixmap3 = new QPixmap(thumbnailsDir + "/" + THUMBNAIL_SCREENSHOT + "/" + thumbnailName);
if ( m_currentBrowser == BROWSER_TYPE_PLAYLISTS
if ( m_currentBrowser == BROWSER_TYPE_PLAYLISTS
&& !currentPlaylistIsSpecial())
acceptDrop = true;
}
@ -4087,7 +4087,7 @@ static enum ui_msg_window_response ui_msg_window_qt_response(ui_msg_window_state
return UI_MSG_RESPONSE_NA;
}
static QFlags<QMessageBox::StandardButton>
static QFlags<QMessageBox::StandardButton>
ui_msg_window_qt_buttons(ui_msg_window_state *state)
{
switch (state->buttons)
@ -4105,7 +4105,7 @@ ui_msg_window_qt_buttons(ui_msg_window_state *state)
return QMessageBox::NoButton;
}
static enum ui_msg_window_response
static enum ui_msg_window_response
ui_msg_window_qt_error(ui_msg_window_state *state)
{
QFlags<QMessageBox::StandardButton> flags = ui_msg_window_qt_buttons(state);
@ -4288,8 +4288,8 @@ void ThumbnailWidget::dragEnterEvent(QDragEnterEvent *event)
event->acceptProposedAction();
}
/* Workaround for QTBUG-72844. Without it, you can't
* drop on this if you first drag over another
/* Workaround for QTBUG-72844. Without it, you can't
* drop on this if you first drag over another
* widget that doesn't accept drops. */
void ThumbnailWidget::dragMoveEvent(QDragMoveEvent *event)
{
@ -5082,7 +5082,7 @@ void LoadCoreWindow::onCoreEnterPressed()
{
QByteArray pathArray;
const char *pathData = NULL;
QTableWidgetItem *selectedCoreItem =
QTableWidgetItem *selectedCoreItem =
m_table->item(m_table->currentRow(), CORE_NAME_COLUMN);
QVariantHash hash = selectedCoreItem->data(
Qt::UserRole).toHash();
@ -5099,8 +5099,8 @@ void LoadCoreWindow::onLoadCustomCoreClicked()
size_t _len;
QString path;
QByteArray pathArray;
char core_ext[32];
char filters[128];
char core_ext[255] = {0};
const char *pathData = NULL;
settings_t *settings = config_get_ptr();
const char *path_dir_libretro = settings->paths.directory_libretro;