From 212fb34293eba17101029cdb834ed1f29f63ab35 Mon Sep 17 00:00:00 2001 From: Jaydeep Date: Sun, 27 Sep 2015 08:19:30 -0600 Subject: [PATCH] servo: Merge #7643 - Check for Extra pointer dereferencing (from jdramani:extra_ptr_dref); r=jdm Solves issue #7640 Source-Repo: https://github.com/servo/servo Source-Revision: 9523283c14f417014ca6d4fa8179c873bbb8f21f --- servo/components/compositing/compositor.rs | 2 +- servo/components/compositing/compositor_layer.rs | 4 ++-- servo/components/net/resource_task.rs | 4 ++-- servo/components/style/animation.rs | 10 +++++----- servo/python/tidy.py | 5 +++++ 5 files changed, 15 insertions(+), 10 deletions(-) diff --git a/servo/components/compositing/compositor.rs b/servo/components/compositing/compositor.rs index 1d9392e873cf..a45dafd54eaf 100644 --- a/servo/components/compositing/compositor.rs +++ b/servo/components/compositing/compositor.rs @@ -681,7 +681,7 @@ impl IOCompositor { fn collect_old_layers(&mut self, pipeline_id: PipelineId, - new_layers: &Vec) { + new_layers: &[LayerProperties]) { let root_layer = match self.scene.root { Some(ref root_layer) => root_layer.clone(), None => return, diff --git a/servo/components/compositing/compositor_layer.rs b/servo/components/compositing/compositor_layer.rs index 7132ee7bb29d..1902849e97f4 100644 --- a/servo/components/compositing/compositor_layer.rs +++ b/servo/components/compositing/compositor_layer.rs @@ -102,7 +102,7 @@ pub trait CompositorLayer { fn collect_old_layers(&self, compositor: &mut IOCompositor, pipeline_id: PipelineId, - new_layers: &Vec) + new_layers: &[LayerProperties]) where Window: WindowMethods; /// Destroys all tiles of all layers, including children, *without* sending them back to the @@ -282,7 +282,7 @@ impl CompositorLayer for Layer { fn collect_old_layers(&self, compositor: &mut IOCompositor, pipeline_id: PipelineId, - new_layers: &Vec) + new_layers: &[LayerProperties]) where Window: WindowMethods { // Traverse children first so that layers are removed // bottom up - allowing each layer being removed to properly diff --git a/servo/components/net/resource_task.rs b/servo/components/net/resource_task.rs index 4337bf1cc314..f84f281ea1b4 100644 --- a/servo/components/net/resource_task.rs +++ b/servo/components/net/resource_task.rs @@ -57,14 +57,14 @@ pub fn start_sending(start_chan: LoadConsumer, metadata: Metadata) -> ProgressSe /// For use by loaders in responding to a Load message that allows content sniffing. pub fn start_sending_sniffed(start_chan: LoadConsumer, metadata: Metadata, - classifier: Arc, partial_body: &Vec) + classifier: Arc, partial_body: &[u8]) -> ProgressSender { start_sending_sniffed_opt(start_chan, metadata, classifier, partial_body).ok().unwrap() } /// For use by loaders in responding to a Load message that allows content sniffing. pub fn start_sending_sniffed_opt(start_chan: LoadConsumer, mut metadata: Metadata, - classifier: Arc, partial_body: &Vec) + classifier: Arc, partial_body: &[u8]) -> Result { if opts::get().sniff_mime_types { // TODO: should be calculated in the resource loader, from pull requeset #4094 diff --git a/servo/components/style/animation.rs b/servo/components/style/animation.rs index b3afc1454251..01ab377bfe62 100644 --- a/servo/components/style/animation.rs +++ b/servo/components/style/animation.rs @@ -736,8 +736,8 @@ impl Interpolate for TextShadowList { /// Check if it's possible to do a direct numerical interpolation /// between these two transform lists. /// http://dev.w3.org/csswg/css-transforms/#transform-transform-animation -fn can_interpolate_list(from_list: &Vec, - to_list: &Vec) -> bool { +fn can_interpolate_list(from_list: &[TransformOperation], + to_list: &[TransformOperation]) -> bool { // Lists must be equal length if from_list.len() != to_list.len() { return false; @@ -763,8 +763,8 @@ fn can_interpolate_list(from_list: &Vec, /// Interpolate two transform lists. /// http://dev.w3.org/csswg/css-transforms/#interpolation-of-transforms -fn interpolate_transform_list(from_list: &Vec, - to_list: &Vec, +fn interpolate_transform_list(from_list: &[TransformOperation], + to_list: &[TransformOperation], time: f64) -> TransformList { let mut result = vec!(); @@ -823,7 +823,7 @@ fn interpolate_transform_list(from_list: &Vec, /// Build an equivalent 'identity transform function list' based /// on an existing transform list. /// http://dev.w3.org/csswg/css-transforms/#none-transform-animation -fn build_identity_transform_list(list: &Vec) -> Vec { +fn build_identity_transform_list(list: &[TransformOperation]) -> Vec { let mut result = vec!(); for operation in list { diff --git a/servo/python/tidy.py b/servo/python/tidy.py index eed16f41f15a..93b30e147f98 100644 --- a/servo/python/tidy.py +++ b/servo/python/tidy.py @@ -111,6 +111,7 @@ def check_by_line(file_name, contents): check_whitespace(idx, line), check_whatwg_url(idx, line), ) + for error in errors: yield error @@ -349,6 +350,10 @@ def check_rust(file_name, contents): yield (idx + 1 - len(mods) + i, message + expected + found) mods = [] + # There should not be any extra pointer dereferencing + if re.search(r": &Vec<", line) is not None: + yield (idx + 1, "use &[T] instead of &Vec") + # Avoid flagging constructs def is_associated_type(match, line, index):