Skip to content

Commit

Permalink
Some minor cleanups - use size_t for return value of strlen,
Browse files Browse the repository at this point in the history
extensions don't need 256-char arrays, etc.
  • Loading branch information
LibretroAdmin committed Aug 15, 2023
1 parent f34481c commit 1765d49
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 37 deletions.
24 changes: 12 additions & 12 deletions gfx/drivers/metal.m
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ - (void)renderMessage:(const char *)msg
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
Expand Down Expand Up @@ -604,7 +604,7 @@ - (void)renderMessage:(const char *)msg

@autoreleasepool
{
NSUInteger max_glyphs = strlen(msg);
size_t max_glyphs = strlen(msg);
if (drop_x || drop_y)
max_glyphs *= 2;

Expand Down Expand Up @@ -792,9 +792,9 @@ - (instancetype)initWithVideo:(const video_info_t *)video

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;
Expand Down Expand Up @@ -997,11 +997,11 @@ - (void)_renderMessage:(const char *)msg
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;
Expand Down Expand Up @@ -1374,7 +1374,7 @@ - (void)setFrame:(CGRect)frame
{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));
}
Expand Down Expand Up @@ -1717,7 +1717,7 @@ - (void)_updateRenderTargets

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)
{
Expand Down Expand Up @@ -1800,8 +1800,8 @@ - (BOOL)setShaderFromPath:(NSString *)path

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 */
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
50 changes: 25 additions & 25 deletions ui/drivers/ui_qt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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;

Expand Down Expand Up @@ -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());
Expand All @@ -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())
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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));
Expand Down Expand Up @@ -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;

Expand All @@ -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())
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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();

Expand Down Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand Down Expand Up @@ -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)
Expand All @@ -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);
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -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();
Expand All @@ -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;
Expand Down

0 comments on commit 1765d49

Please sign in to comment.