From 2367b1c9ff5c034cf14a7f323e01c431445e1724 Mon Sep 17 00:00:00 2001 From: Jules Villard Date: Fri, 13 Nov 2015 08:16:20 -0800 Subject: [PATCH] cleanup two c tests that were causing clang warnings Summary: public This caused scary red output in buck. Reviewed By: akotulski Differential Revision: D2652135 fb-gh-sync-id: 52d6e7e --- .../c/errors/arithmetic/array_out_of_bounds.c | 6 ++++ .../c/errors/dangling_deref/dpd.c | 36 +++++++++---------- .../c/errors/null_dereference/angelism.c | 3 ++ 3 files changed, 26 insertions(+), 19 deletions(-) diff --git a/infer/tests/codetoanalyze/c/errors/arithmetic/array_out_of_bounds.c b/infer/tests/codetoanalyze/c/errors/arithmetic/array_out_of_bounds.c index 1c6abcf7e..220f5f79c 100644 --- a/infer/tests/codetoanalyze/c/errors/arithmetic/array_out_of_bounds.c +++ b/infer/tests/codetoanalyze/c/errors/arithmetic/array_out_of_bounds.c @@ -7,17 +7,23 @@ * of patent rights can be found in the PATENTS file in the same directory. */ +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warray-bounds" void bound_error() { int a[7]; a[7] = 4; } +#pragma clang diagnostic pop void nested_array_ok() { int a[3][4][5]; a[2][3][4] = 0; } +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Warray-bounds" void bound_error_nested() { int a[3][4][5]; a[4][3][2] = 0; } +#pragma clang diagnostic pop diff --git a/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c b/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c index bba2069ea..61a1a7ca4 100644 --- a/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c +++ b/infer/tests/codetoanalyze/c/errors/dangling_deref/dpd.c @@ -1,43 +1,41 @@ +/* +* Copyright (c) 2015 - present Facebook, Inc. +* All rights reserved. +* +* This source code is licensed under the BSD style license found in the +* LICENSE file in the root directory of this source tree. An additional grant +* of patent rights can be found in the PATENTS file in the same directory. +*/ + #include #include int *set42(int* x) { - - *x=42; + *x = 42; return x; } void nodpd () { - - int w,z; - - z=set42(&w); - + int w,*z; + z = set42(&w); } void nodpd1 () { - - int *y = malloc(sizeof(int)); + int *y = malloc(sizeof(int)); int *z; - z=set42(y); + z = set42(y); free(y); - } - - void dpd () { - int *y; int *z; - z=set42(y); + z = set42(y); } - void intraprocdpd () { - int *y; int *z; - *y=42; - z=y; + *y = 42; + z = y; } diff --git a/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c b/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c index 9d2a2d719..aa4041f3f 100644 --- a/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c +++ b/infer/tests/codetoanalyze/c/errors/null_dereference/angelism.c @@ -32,6 +32,9 @@ struct delicious *skip_function_with_no_spec(void) { } extern struct delicious *bakery(struct delicious **cake); +extern struct delicious *bakery2(struct delicious **cake, + struct delicious **pie); +extern struct delicious *returnPassByRef(); struct delicious *skip_external_function(void) { struct delicious *cake = NULL;