chore: clean up implicit conversions (#4611)

This commit is contained in:
Andy Grundman 2026-01-22 14:39:52 -05:00 committed by GitHub
commit aea9512682
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
13 changed files with 66 additions and 66 deletions

View file

@ -114,7 +114,7 @@ namespace audio {
while (auto sample = samples->pop()) {
buffer_t packet {1400};
int bytes = opus_multistream_encode_float(opus.get(), sample->data(), frame_size, std::begin(packet), packet.size());
int bytes = opus_multistream_encode_float(opus.get(), sample->data(), frame_size, std::begin(packet), (opus_int32) packet.size());
if (bytes < 0) {
BOOST_LOG(error) << "Couldn't encode audio: "sv << opus_strerror(bytes);
packets->stop();

View file

@ -775,7 +775,7 @@ namespace config {
if (val.size() >= 2 && val.substr(0, 2) == "0x"sv) {
input = util::from_hex<int>(val.substr(2));
} else {
input = util::from_view(val);
input = (int) util::from_view(val);
}
vars.erase(it);
@ -979,7 +979,7 @@ namespace config {
if (val.size() >= 2 && val.substr(0, 2) == "0x"sv) {
tmp = util::from_hex<int>(val.substr(2));
} else {
tmp = util::from_view(val);
tmp = (int) util::from_view(val);
}
input.emplace_back(tmp);
}

View file

@ -163,7 +163,7 @@ namespace confighttp {
auto &rawAuth = auth->second;
auto authData = SimpleWeb::Crypto::Base64::decode(rawAuth.substr("Basic "sv.length()));
int index = authData.find(':');
auto index = (int) authData.find(':');
if (index >= authData.size() - 1) {
return false;
}

View file

@ -100,7 +100,7 @@ namespace crypto {
return -1;
}
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv->size(), nullptr) != 1) {
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, (int) iv->size(), nullptr) != 1) {
return -1;
}
@ -120,7 +120,7 @@ namespace crypto {
return -1;
}
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, iv->size(), nullptr) != 1) {
if (EVP_CIPHER_CTX_ctrl(ctx.get(), EVP_CTRL_GCM_SET_IVLEN, (int) iv->size(), nullptr) != 1) {
return -1;
}
@ -163,11 +163,11 @@ namespace crypto {
int update_outlen, final_outlen;
if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), cipher.size()) != 1) {
if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), (int) cipher.size()) != 1) {
return -1;
}
if (EVP_CIPHER_CTX_ctrl(decrypt_ctx.get(), EVP_CTRL_GCM_SET_TAG, tag.size(), const_cast<char *>(tag.data())) != 1) {
if (EVP_CIPHER_CTX_ctrl(decrypt_ctx.get(), EVP_CTRL_GCM_SET_TAG, (int) tag.size(), const_cast<char *>(tag.data())) != 1) {
return -1;
}
@ -198,7 +198,7 @@ namespace crypto {
int update_outlen, final_outlen;
// Encrypt into the caller's buffer
if (EVP_EncryptUpdate(encrypt_ctx.get(), ciphertext, &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) {
if (EVP_EncryptUpdate(encrypt_ctx.get(), ciphertext, &update_outlen, (const std::uint8_t *) plaintext.data(), (int) plaintext.size()) != 1) {
return -1;
}
@ -234,7 +234,7 @@ namespace crypto {
int update_outlen, final_outlen;
if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), cipher.size()) != 1) {
if (EVP_DecryptUpdate(decrypt_ctx.get(), plaintext.data(), &update_outlen, (const std::uint8_t *) cipher.data(), (int) cipher.size()) != 1) {
return -1;
}
@ -262,7 +262,7 @@ namespace crypto {
int update_outlen, final_outlen;
// Encrypt into the caller's buffer
if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher.data(), &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) {
if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher.data(), &update_outlen, (const std::uint8_t *) plaintext.data(), (int) plaintext.size()) != 1) {
return -1;
}
@ -293,7 +293,7 @@ namespace crypto {
int update_outlen, final_outlen;
// Encrypt into the caller's buffer
if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &update_outlen, (const std::uint8_t *) plaintext.data(), plaintext.size()) != 1) {
if (EVP_EncryptUpdate(encrypt_ctx.get(), cipher, &update_outlen, (const std::uint8_t *) plaintext.data(), (int) plaintext.size()) != 1) {
return -1;
}
@ -343,7 +343,7 @@ namespace crypto {
x509_t x509(const std::string_view &x) {
bio_t io {BIO_new(BIO_s_mem())};
BIO_write(io.get(), x.data(), x.size());
BIO_write(io.get(), x.data(), (int) x.size());
x509_t p;
PEM_read_bio_X509(io.get(), &p, nullptr, nullptr);
@ -354,7 +354,7 @@ namespace crypto {
pkey_t pkey(const std::string_view &k) {
bio_t io {BIO_new(BIO_s_mem())};
BIO_write(io.get(), k.data(), k.size());
BIO_write(io.get(), k.data(), (int) k.size());
pkey_t p = nullptr;
PEM_read_bio_PrivateKey(io.get(), &p, nullptr, nullptr);
@ -395,7 +395,7 @@ namespace crypto {
std::string r;
r.resize(bytes);
RAND_bytes((uint8_t *) r.data(), r.size());
RAND_bytes((uint8_t *) r.data(), (int) r.size());
return r;
}
@ -459,7 +459,7 @@ namespace crypto {
X509_set_pubkey(x509.get(), pkey.get());
auto name = X509_get_subject_name(x509.get());
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (const std::uint8_t *) cn.data(), cn.size(), -1, 0);
X509_NAME_add_entry_by_txt(name, "CN", MBSTRING_ASC, (const std::uint8_t *) cn.data(), (int) cn.size(), -1, 0);
X509_set_issuer_name(x509.get(), name);
X509_sign(x509.get(), pkey.get(), EVP_sha256());

View file

@ -126,7 +126,7 @@ namespace display_device {
if (result > std::numeric_limits<unsigned int>::max()) {
throw std::out_of_range("stou");
}
return result;
return (int) result;
}
/**

View file

@ -858,7 +858,7 @@ namespace input {
return;
}
auto size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
int size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
platf::unicode(platf_input, packet->text, size);
}

View file

@ -134,7 +134,7 @@ namespace nvenc {
};
std::vector<GUID> encode_guids(encode_guid_count);
if (nvenc_failed(nvenc->nvEncGetEncodeGUIDs(encoder, encode_guids.data(), encode_guids.size(), &encode_guid_count))) {
if (nvenc_failed(nvenc->nvEncGetEncodeGUIDs(encoder, encode_guids.data(), (uint32_t) encode_guids.size(), &encode_guid_count))) {
BOOST_LOG(error) << "NvEnc: NvEncGetEncodeGUIDs() failed: " << last_nvenc_error_string;
return false;
}

View file

@ -305,12 +305,12 @@ namespace nvhttp {
x++;
}
launch_session->unique_id = (get_arg(args, "uniqueid", "unknown"));
launch_session->appid = util::from_view(get_arg(args, "appid", "unknown"));
launch_session->appid = (int) util::from_view(get_arg(args, "appid", "unknown"));
launch_session->enable_sops = util::from_view(get_arg(args, "sops", "0"));
launch_session->surround_info = util::from_view(get_arg(args, "surroundAudioInfo", "196610"));
launch_session->surround_info = (int) util::from_view(get_arg(args, "surroundAudioInfo", "196610"));
launch_session->surround_params = (get_arg(args, "surroundParams", ""));
launch_session->continuous_audio = util::from_view(get_arg(args, "continuousAudio", "0"));
launch_session->gcmap = util::from_view(get_arg(args, "gcmap", "0"));
launch_session->gcmap = (int) util::from_view(get_arg(args, "gcmap", "0"));
launch_session->enable_hdr = util::from_view(get_arg(args, "hdrMode", "0"));
// Encrypted RTSP is enabled with client reported corever >= 1
@ -331,7 +331,7 @@ namespace nvhttp {
RAND_bytes((unsigned char *) &launch_session->control_connect_data, sizeof(launch_session->control_connect_data));
launch_session->iv.resize(16);
uint32_t prepend_iv = util::endian::big<uint32_t>(util::from_view(get_arg(args, "rikeyid")));
uint32_t prepend_iv = util::endian::big<uint32_t>((int) util::from_view(get_arg(args, "rikeyid")));
auto prepend_iv_p = (uint8_t *) &prepend_iv;
std::copy(prepend_iv_p, prepend_iv_p + sizeof(prepend_iv), std::begin(launch_session->iv));
return launch_session;
@ -893,7 +893,7 @@ namespace nvhttp {
}
if (appid > 0) {
auto err = proc::proc.execute(appid, launch_session);
auto err = proc::proc.execute((int) appid, launch_session);
if (err) {
tree.put("root.<xmlattr>.status_code", err);
tree.put("root.<xmlattr>.status_message", "Failed to start the specified application");
@ -1041,7 +1041,7 @@ namespace nvhttp {
print_req<SunshineHTTPS>(request);
auto args = request->parse_query_string();
auto app_image = proc::proc.get_app_image(util::from_view(get_arg(args, "appid")));
auto app_image = proc::proc.get_app_image((int) util::from_view(get_arg(args, "appid")));
std::ifstream in(app_image, std::ios::binary);
SimpleWeb::CaseInsensitiveMultimap headers;

View file

@ -34,7 +34,7 @@ namespace platf {
std::copy_n(std::begin(vectorBuffer), sample_size, std::begin(sample_in));
TPCircularBufferConsume(&av_audio_capture->audioSampleBuffer, sample_size * sizeof(float));
TPCircularBufferConsume(&av_audio_capture->audioSampleBuffer, (uint32_t) sample_size * sizeof(float));
return capture_e::ok;
}

View file

@ -33,7 +33,7 @@
using namespace std::literals;
namespace fs = std::filesystem;
namespace bp = boost::process;
namespace bp = boost::process::v1;
namespace platf {

View file

@ -224,7 +224,7 @@ namespace rtsp_stream {
}
msg_t req {new msg_t::element_type {}};
if (auto status = parseRtspMessage(req.get(), (char *) plaintext.data(), plaintext.size())) {
if (auto status = parseRtspMessage(req.get(), (char *) plaintext.data(), (int) plaintext.size())) {
BOOST_LOG(error) << "Malformed RTSP message: ["sv << status << ']';
respond(socket->sock, *socket->session, nullptr, 400, "BAD REQUEST", 0, {});
@ -290,7 +290,7 @@ namespace rtsp_stream {
auto end = socket->begin + bytes;
msg_t req {new msg_t::element_type {}};
if (auto status = parseRtspMessage(req.get(), socket->msg_buf.data(), (std::size_t) (end - socket->msg_buf.data()))) {
if (auto status = parseRtspMessage(req.get(), socket->msg_buf.data(), (int) (end - socket->msg_buf.data()))) {
BOOST_LOG(error) << "Malformed RTSP message: ["sv << status << ']';
respond(socket->sock, *socket->session, nullptr, 400, "BAD REQUEST", 0, {});
@ -315,7 +315,7 @@ namespace rtsp_stream {
return (bool) std::isdigit(ch);
});
content_length = util::from_chars(begin, std::end(content));
content_length = (int) util::from_chars(begin, std::end(content));
break;
}
}
@ -541,7 +541,7 @@ namespace rtsp_stream {
*/
int session_count() {
auto lg = _session_slots.lock();
return _session_slots->size();
return (int) _session_slots->size();
}
safe::event_t<std::shared_ptr<launch_session_t>> launch_event;
@ -966,38 +966,38 @@ namespace rtsp_stream {
std::int64_t configuredBitrateKbps;
config.audio.flags[audio::config_t::HOST_AUDIO] = session.host_audio;
try {
config.audio.channels = util::from_view(args.at("x-nv-audio.surround.numChannels"sv));
config.audio.mask = util::from_view(args.at("x-nv-audio.surround.channelMask"sv));
config.audio.packetDuration = util::from_view(args.at("x-nv-aqos.packetDuration"sv));
config.audio.channels = (int) util::from_view(args.at("x-nv-audio.surround.numChannels"sv));
config.audio.mask = (int) util::from_view(args.at("x-nv-audio.surround.channelMask"sv));
config.audio.packetDuration = (int) util::from_view(args.at("x-nv-aqos.packetDuration"sv));
config.audio.flags[audio::config_t::HIGH_QUALITY] =
util::from_view(args.at("x-nv-audio.surround.AudioQuality"sv));
config.controlProtocolType = util::from_view(args.at("x-nv-general.useReliableUdp"sv));
config.packetsize = util::from_view(args.at("x-nv-video[0].packetSize"sv));
config.minRequiredFecPackets = util::from_view(args.at("x-nv-vqos[0].fec.minRequiredFecPackets"sv));
config.mlFeatureFlags = util::from_view(args.at("x-ml-general.featureFlags"sv));
config.audioQosType = util::from_view(args.at("x-nv-aqos.qosTrafficType"sv));
config.videoQosType = util::from_view(args.at("x-nv-vqos[0].qosTrafficType"sv));
config.encryptionFlagsEnabled = util::from_view(args.at("x-ss-general.encryptionEnabled"sv));
config.controlProtocolType = (int) util::from_view(args.at("x-nv-general.useReliableUdp"sv));
config.packetsize = (int) util::from_view(args.at("x-nv-video[0].packetSize"sv));
config.minRequiredFecPackets = (int) util::from_view(args.at("x-nv-vqos[0].fec.minRequiredFecPackets"sv));
config.mlFeatureFlags = (int) util::from_view(args.at("x-ml-general.featureFlags"sv));
config.audioQosType = (int) util::from_view(args.at("x-nv-aqos.qosTrafficType"sv));
config.videoQosType = (int) util::from_view(args.at("x-nv-vqos[0].qosTrafficType"sv));
config.encryptionFlagsEnabled = (uint32_t) util::from_view(args.at("x-ss-general.encryptionEnabled"sv));
// Legacy clients use nvFeatureFlags to indicate support for audio encryption
if (util::from_view(args.at("x-nv-general.featureFlags"sv)) & 0x20) {
config.encryptionFlagsEnabled |= SS_ENC_AUDIO;
}
config.monitor.height = util::from_view(args.at("x-nv-video[0].clientViewportHt"sv));
config.monitor.width = util::from_view(args.at("x-nv-video[0].clientViewportWd"sv));
config.monitor.framerate = util::from_view(args.at("x-nv-video[0].maxFPS"sv));
config.monitor.framerateX100 = util::from_view(args.at("x-nv-video[0].clientRefreshRateX100"sv));
config.monitor.bitrate = util::from_view(args.at("x-nv-vqos[0].bw.maximumBitrateKbps"sv));
config.monitor.slicesPerFrame = util::from_view(args.at("x-nv-video[0].videoEncoderSlicesPerFrame"sv));
config.monitor.numRefFrames = util::from_view(args.at("x-nv-video[0].maxNumReferenceFrames"sv));
config.monitor.encoderCscMode = util::from_view(args.at("x-nv-video[0].encoderCscMode"sv));
config.monitor.videoFormat = util::from_view(args.at("x-nv-vqos[0].bitStreamFormat"sv));
config.monitor.dynamicRange = util::from_view(args.at("x-nv-video[0].dynamicRangeMode"sv));
config.monitor.chromaSamplingType = util::from_view(args.at("x-ss-video[0].chromaSamplingType"sv));
config.monitor.enableIntraRefresh = util::from_view(args.at("x-ss-video[0].intraRefresh"sv));
config.monitor.height = (int) util::from_view(args.at("x-nv-video[0].clientViewportHt"sv));
config.monitor.width = (int) util::from_view(args.at("x-nv-video[0].clientViewportWd"sv));
config.monitor.framerate = (int) util::from_view(args.at("x-nv-video[0].maxFPS"sv));
config.monitor.framerateX100 = (int) util::from_view(args.at("x-nv-video[0].clientRefreshRateX100"sv));
config.monitor.bitrate = (int) util::from_view(args.at("x-nv-vqos[0].bw.maximumBitrateKbps"sv));
config.monitor.slicesPerFrame = (int) util::from_view(args.at("x-nv-video[0].videoEncoderSlicesPerFrame"sv));
config.monitor.numRefFrames = (int) util::from_view(args.at("x-nv-video[0].maxNumReferenceFrames"sv));
config.monitor.encoderCscMode = (int) util::from_view(args.at("x-nv-video[0].encoderCscMode"sv));
config.monitor.videoFormat = (int) util::from_view(args.at("x-nv-vqos[0].bitStreamFormat"sv));
config.monitor.dynamicRange = (int) util::from_view(args.at("x-nv-video[0].dynamicRangeMode"sv));
config.monitor.chromaSamplingType = (int) util::from_view(args.at("x-ss-video[0].chromaSamplingType"sv));
config.monitor.enableIntraRefresh = (int) util::from_view(args.at("x-ss-video[0].intraRefresh"sv));
configuredBitrateKbps = util::from_view(args.at("x-ml-video.configuredBitrateKbps"sv));
} catch (std::out_of_range &) {
@ -1067,7 +1067,7 @@ namespace rtsp_stream {
configuredBitrateKbps -= std::min((std::int64_t) 500, configuredBitrateKbps / 10);
BOOST_LOG(debug) << "Final adjusted video encoding bitrate is "sv << configuredBitrateKbps << " Kbps"sv;
config.monitor.bitrate = configuredBitrateKbps;
config.monitor.bitrate = (int) configuredBitrateKbps;
}
if (config.monitor.videoFormat == 1 && video::active_hevc_mode == 1) {

View file

@ -251,7 +251,7 @@ namespace stream {
// If encryption isn't enabled
if (!encrypted) {
std::copy(std::begin(plaintext), std::end(plaintext), destination);
return plaintext.size();
return (int) plaintext.size();
}
return cbc.encrypt(std::string_view {(char *) std::begin(plaintext), plaintext.size()}, destination, &iv);
@ -567,7 +567,7 @@ namespace stream {
void control_server_t::iterate(std::chrono::milliseconds timeout) {
ENetEvent event;
auto res = enet_host_service(_host.get(), &event, timeout.count());
auto res = enet_host_service(_host.get(), &event, (enet_uint32) timeout.count());
if (res > 0) {
auto session = get_session(event.peer, event.data);
@ -698,9 +698,9 @@ namespace stream {
}
// packets = parity_shards + data_shards
rs_t rs {reed_solomon_new(data_shards, parity_shards)};
rs_t rs {reed_solomon_new((int) data_shards, (int) parity_shards)};
reed_solomon_encode(rs.get(), shards_p.begin(), nr_shards, blocksize);
reed_solomon_encode(rs.get(), shards_p.begin(), (int) nr_shards, (int) blocksize);
}
return {
@ -1427,7 +1427,7 @@ namespace stream {
for (int x = 0; x < packets; ++x) {
auto *inspect = (video_packet_raw_t *) &current_payload[x * blocksize];
inspect->packet.frameIndex = packet->frame_index();
inspect->packet.frameIndex = (uint32_t) packet->frame_index();
inspect->packet.streamPacketIndex = ((uint32_t) lowseq + x) << 8;
// Match multiFecFlags with Moonlight
@ -1479,16 +1479,16 @@ namespace stream {
auto *inspect = (video_packet_raw_t *) shards.data(x);
inspect->packet.fecInfo =
(x << 12 |
shards.data_shards << 22 |
shards.percentage << 4);
(uint32_t) (x << 12 |
shards.data_shards << 22 |
shards.percentage << 4);
inspect->rtp.header = 0x80 | FLAG_EXTENSION;
inspect->rtp.sequenceNumber = util::endian::big<uint16_t>(lowseq + x);
inspect->rtp.timestamp = util::endian::big<uint32_t>(timestamp);
inspect->packet.multiFecBlocks = (blockIndex << 4) | ((fec_blocks_needed - 1) << 6);
inspect->packet.frameIndex = packet->frame_index();
inspect->packet.frameIndex = (uint32_t) packet->frame_index();
// Encrypt this shard if video encryption is enabled
if (session->video.cipher) {
@ -1506,7 +1506,7 @@ namespace stream {
// Encrypt the target buffer in place
auto *prefix = (video_packet_enc_prefix_t *) shards.prefix(x);
prefix->frameNumber = packet->frame_index();
prefix->frameNumber = (std::uint32_t) packet->frame_index();
std::copy(std::begin(iv), std::end(iv), prefix->iv);
session->video.cipher->encrypt(std::string_view {(char *) inspect, (size_t) blocksize}, prefix->tag, (uint8_t *) inspect, &iv);
}

View file

@ -56,9 +56,9 @@ namespace upnp {
*/
int UPNP_GetValidIGDStatus(device_t &device, urls_t *urls, IGDdatas *data, std::array<char, INET6_ADDRESS_STRLEN> &lan_addr) {
#if (MINIUPNPC_API_VERSION >= 18)
return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), lan_addr.size(), nullptr, 0);
return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), (int) lan_addr.size(), nullptr, 0);
#else
return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), lan_addr.size());
return UPNP_GetValidIGD(device.get(), &urls->el, data, lan_addr.data(), (int) lan_addr.size());
#endif
}