Advertisement
Guest User

Untitled

a guest
Oct 28th, 2016
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.51 KB | None | 0 0
  1. int f(int z) {
  2. return z + (z*2) + z/3 + z*z + 23;
  3. }
  4.  
  5.  
  6. int main()
  7. {
  8. int i = 7;
  9. f(i); ///// <<----- here I disregard the return value
  10.  
  11. return 1;
  12. }
  13.  
  14. #define WARN_UNUSED __attribute__((warn_unused_result))
  15.  
  16. int WARN_UNUSED f(int z) {
  17. return z + (z*2) + z/3 + z*z + 23;
  18. }
  19.  
  20. int main()
  21. {
  22. int i = 7;
  23. f(i); ///// <<----- here i disregard the return value
  24. return 1;
  25. }
  26.  
  27. $ gcc test.c
  28. test.c: In function `main':
  29. test.c:16: warning: ignoring return value of `f', declared with
  30. attribute warn_unused_result
  31.  
  32. unsigned long __must_check copy_to_user(void __user *to,
  33. const void *from, unsigned long n);
  34.  
  35. int fn() __attribute__((warn_unused_result));
  36.  
  37. class return_value
  38. {
  39. public:
  40. explicit return_value(T value)
  41. :value(value), checked(false)
  42. {
  43. }
  44.  
  45. return_value(const return_value& other)
  46. :value(other.value), checked(other.checked)
  47. {
  48. other.checked = true;
  49. }
  50.  
  51. return_value& operator=(const return_value& other)
  52. {
  53. if( this != &other )
  54. {
  55. assert(checked);
  56. value = other.value;
  57. checked = other.checked;
  58. other.checked = true;
  59. }
  60. }
  61.  
  62. ~return_value(const return_value& other)
  63. {
  64. assert(checked);
  65. }
  66.  
  67. T get_value()const {
  68. checked = true;
  69. return value;
  70. }
  71.  
  72. private:
  73. mutable bool checked;
  74. T value;
  75. };
  76.  
  77. grep -rn "function_name" * | grep -v "="
  78.  
  79. if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
  80. signal(SIGHUP, sighandler);
  81.  
  82. if ((old = signal(SIGHUP, SIG_IGN)) != SIG_IGN)
  83. old = signal(SIGHUP, sighandler);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement