Merge pull request #949 from mwkroening/warnings

Fix compiler warnings
This commit is contained in:
Cobrand
2019-12-30 17:20:33 +01:00
committed by GitHub
6 changed files with 39 additions and 41 deletions
+1 -1
View File
@@ -221,7 +221,7 @@ fn patch_sdl2(sdl2_source_path: &Path) {
// ever have more than one hunk.
assert!(added_file.len() == 1);
let file_path = sdl2_source_path.join(added_file.path());
let mut dst_file = fs::File::create(&file_path)
let dst_file = fs::File::create(&file_path)
.expect(&format!(
"Failed to create file {}",
file_path.to_string_lossy()));
+2 -2
View File
@@ -1,7 +1,7 @@
//! Framerate control
use libc;
use libc::{c_void, uint32_t, size_t};
use libc::{c_void, size_t};
use std::mem;
use ::get_error;
use sys::gfx;
@@ -24,7 +24,7 @@ impl FPSManager {
/// Set the framerate in Hz.
pub fn set_framerate(&mut self, rate: u32) -> Result<(), String> {
let ret = unsafe { gfx::framerate::SDL_setFramerate(self.raw, rate as uint32_t) };
let ret = unsafe { gfx::framerate::SDL_setFramerate(self.raw, rate as u32) };
match ret {
0 => Ok(()),
_ => Err(get_error())
+6 -6
View File
@@ -31,9 +31,9 @@ use get_error;
use sys;
use sys::image;
/// InitFlags are passed to init() to control which subsystem
/// functionality to load.
bitflags! {
/// InitFlags are passed to init() to control which subsystem
/// functionality to load.
pub struct InitFlag : u32 {
const JPG = image::IMG_InitFlags_IMG_INIT_JPG as u32;
const PNG = image::IMG_InitFlags_IMG_INIT_PNG as u32;
@@ -46,16 +46,16 @@ bitflags! {
impl ::std::fmt::Display for InitFlag {
fn fmt(&self, f: &mut ::std::fmt::Formatter) -> ::std::fmt::Result {
if self.contains(InitFlag::JPG) {
try!(f.write_str("INIT_JPG "));
f.write_str("INIT_JPG ")?;
}
if self.contains(InitFlag::PNG) {
try!(f.write_str("INIT_PNG "));
f.write_str("INIT_PNG ")?;
}
if self.contains(InitFlag::TIF) {
try!(f.write_str("INIT_TIF "));
f.write_str("INIT_TIF ")?;
}
if self.contains(InitFlag::WEBP) {
try!(f.write_str("INIT_WEBP "));
f.write_str("INIT_WEBP ")?;
}
Ok(())
}
+22 -24
View File
@@ -28,7 +28,7 @@ use std::str::from_utf8;
use std::borrow::ToOwned;
use std::path::Path;
use libc::c_void;
use libc::{c_int, uint16_t, c_double, c_uint};
use libc::{c_int, c_double, c_uint};
use ::get_error;
use ::rwops::RWops;
use ::version::Version;
@@ -38,29 +38,27 @@ use sys::mixer;
// This comes from SDL_audio.h
#[allow(non_camel_case_types)]
mod ll {
use libc::uint16_t;
pub const AUDIO_U8: uint16_t = 0x0008;
pub const AUDIO_S8: uint16_t = 0x8008;
pub const AUDIO_U16LSB: uint16_t = 0x0010;
pub const AUDIO_S16LSB: uint16_t = 0x8010;
pub const AUDIO_U16MSB: uint16_t = 0x1010;
pub const AUDIO_S16MSB: uint16_t = 0x9010;
pub const AUDIO_U16: uint16_t = AUDIO_U16LSB;
pub const AUDIO_S16: uint16_t = AUDIO_S16LSB;
pub const AUDIO_S32LSB: uint16_t = 0x8020;
pub const AUDIO_S32MSB: uint16_t = 0x9020;
pub const AUDIO_S32: uint16_t = AUDIO_S32LSB;
pub const AUDIO_F32LSB: uint16_t = 0x8120;
pub const AUDIO_F32MSB: uint16_t = 0x9120;
pub const AUDIO_F32: uint16_t = AUDIO_F32LSB;
pub const AUDIO_U16SYS: uint16_t = AUDIO_U16LSB;
pub const AUDIO_S16SYS: uint16_t = AUDIO_S16LSB;
pub const AUDIO_S32SYS: uint16_t = AUDIO_S32LSB;
pub const AUDIO_F32SYS: uint16_t = AUDIO_F32LSB;
pub const AUDIO_U8: u16 = 0x0008;
pub const AUDIO_S8: u16 = 0x8008;
pub const AUDIO_U16LSB: u16 = 0x0010;
pub const AUDIO_S16LSB: u16 = 0x8010;
pub const AUDIO_U16MSB: u16 = 0x1010;
pub const AUDIO_S16MSB: u16 = 0x9010;
pub const AUDIO_U16: u16 = AUDIO_U16LSB;
pub const AUDIO_S16: u16 = AUDIO_S16LSB;
pub const AUDIO_S32LSB: u16 = 0x8020;
pub const AUDIO_S32MSB: u16 = 0x9020;
pub const AUDIO_S32: u16 = AUDIO_S32LSB;
pub const AUDIO_F32LSB: u16 = 0x8120;
pub const AUDIO_F32MSB: u16 = 0x9120;
pub const AUDIO_F32: u16 = AUDIO_F32LSB;
pub const AUDIO_U16SYS: u16 = AUDIO_U16LSB;
pub const AUDIO_S16SYS: u16 = AUDIO_S16LSB;
pub const AUDIO_S32SYS: u16 = AUDIO_S32LSB;
pub const AUDIO_F32SYS: u16 = AUDIO_F32LSB;
}
pub type AudioFormat = uint16_t;
pub type AudioFormat = u16;
pub const AUDIO_U8: AudioFormat = ll::AUDIO_U8;
pub const AUDIO_S8: AudioFormat = ll::AUDIO_S8;
@@ -196,7 +194,7 @@ pub fn close_audio() {
/// Get the actual audio format in use by the opened audio device.
pub fn query_spec() -> Result<(i32, AudioFormat, i32), String> {
let mut frequency: c_int = 0;
let mut format: uint16_t = 0;
let mut format: u16 = 0;
let mut channels: c_int = 0;
let ret = unsafe { mixer::Mix_QuerySpec(&mut frequency, &mut format, &mut channels) };
if ret == 0 {
@@ -239,7 +237,7 @@ impl Drop for Chunk {
impl Chunk {
/// Load file for use as a sample.
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Chunk, String> {
let raw = unsafe { mixer::Mix_LoadWAV_RW(try!(RWops::from_file(path, "rb")).raw(), 0) };
let raw = unsafe { mixer::Mix_LoadWAV_RW(RWops::from_file(path, "rb")?.raw(), 0) };
if raw.is_null() {
Err(get_error())
} else {
+1 -1
View File
@@ -96,7 +96,7 @@ impl error::Error for InitError {
}
}
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
InitError::AlreadyInitializedError => {
None
+7 -7
View File
@@ -69,7 +69,7 @@ impl error::Error for FontError {
}
}
fn cause(&self) -> Option<&error::Error> {
fn cause(&self) -> Option<&dyn error::Error> {
match *self {
FontError::InvalidLatin1Text(ref error) => {
Some(error)
@@ -149,7 +149,7 @@ impl<'f,'text> PartialRendering<'f,'text> {
/// for an explanation.
pub fn solid<'b, T>(self, color: T )
-> FontResult<Surface<'b>> where T: Into<Color> {
let source = try!(self.text.convert());
let source = self.text.convert()?;
let color = color.into().into();
let raw = unsafe {
match self.text {
@@ -171,7 +171,7 @@ impl<'f,'text> PartialRendering<'f,'text> {
/// for an explanation.
pub fn shaded<'b, T>(self, color: T, background: T)
-> FontResult<Surface<'b>> where T: Into<Color> {
let source = try!(self.text.convert());
let source = self.text.convert()?;
let foreground = color.into().into();
let background = background.into().into();
let raw = unsafe {
@@ -194,7 +194,7 @@ impl<'f,'text> PartialRendering<'f,'text> {
/// for an explanation.
pub fn blended<'b, T>(self, color: T)
-> FontResult<Surface<'b>> where T: Into<Color> {
let source = try!(self.text.convert());
let source = self.text.convert()?;
let color = color.into().into();
let raw = unsafe {
match self.text {
@@ -217,7 +217,7 @@ impl<'f,'text> PartialRendering<'f,'text> {
/// for an explanation of the mode.
pub fn blended_wrapped<'b, T>(self, color: T, wrap_max_width: u32)
-> FontResult<Surface<'b>> where T: Into<Color> {
let source = try!(self.text.convert());
let source = self.text.convert()?;
let color = color.into().into();
let raw = unsafe {
match self.text {
@@ -334,7 +334,7 @@ impl<'ttf,'r> Font<'ttf,'r> {
/// Returns the width and height of the given text when rendered using this
/// font.
pub fn size_of(&self, text: &str) -> FontResult<(u32, u32)> {
let c_string = try!(RenderableText::Utf8(text).convert());
let c_string = RenderableText::Utf8(text).convert()?;
let (res, size) = unsafe {
let mut w = 0; // mutated by C code
let mut h = 0; // mutated by C code
@@ -353,7 +353,7 @@ impl<'ttf,'r> Font<'ttf,'r> {
#[allow(unused_mut)]
pub fn size_of_latin1(&self, text: &[u8])
-> FontResult<(u32, u32)> {
let c_string = try!(RenderableText::Latin1(text).convert());
let c_string = RenderableText::Latin1(text).convert()?;
let (res, size) = unsafe {
let mut w : i32 = 0; // mutated by C code
let mut h : i32 = 0; // mutated by C code