Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(188)

Side by Side Diff: ipc/ipc_message_utils.h

Issue 1810243002: Check for unstable types in IPC messages. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « ipc/ipc_message_macros.h ('k') | tools/clang/plugins/CMakeLists.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef IPC_IPC_MESSAGE_UTILS_H_ 5 #ifndef IPC_IPC_MESSAGE_UTILS_H_
6 #define IPC_IPC_MESSAGE_UTILS_H_ 6 #define IPC_IPC_MESSAGE_UTILS_H_
7 7
8 #include <limits.h> 8 #include <limits.h>
9 #include <stddef.h> 9 #include <stddef.h>
10 #include <stdint.h> 10 #include <stdint.h>
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
70 std::string params; 70 std::string params;
71 }; 71 };
72 72
73 //----------------------------------------------------------------------------- 73 //-----------------------------------------------------------------------------
74 74
75 // A dummy struct to place first just to allow leading commas for all 75 // A dummy struct to place first just to allow leading commas for all
76 // members in the macro-generated constructor initializer lists. 76 // members in the macro-generated constructor initializer lists.
77 struct NoParams { 77 struct NoParams {
78 }; 78 };
79 79
80 // Specializations are checked by 'IPC checker' part of find-bad-constructs
81 // Clang plugin (see WriteParam() below for the details).
82 template <typename... Ts>
83 struct CheckedTuple {
84 typedef std::tuple<Ts...> Tuple;
85 };
86
80 template <class P> 87 template <class P>
81 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) { 88 static inline void GetParamSize(base::PickleSizer* sizer, const P& p) {
82 typedef typename SimilarTypeTraits<P>::Type Type; 89 typedef typename SimilarTypeTraits<P>::Type Type;
83 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p)); 90 ParamTraits<Type>::GetSize(sizer, static_cast<const Type&>(p));
84 } 91 }
85 92
93 // This function is checked by 'IPC checker' part of find-bad-constructs
94 // Clang plugin to make it's not called on the following types:
95 // 1. long / unsigned long (but not typedefs to)
96 // 2. intmax_t, uintmax_t, intptr_t, uintptr_t, wint_t,
97 // size_t, rsize_t, ssize_t, ptrdiff_t, dev_t, off_t, clock_t,
98 // time_t, suseconds_t (including typedefs to)
99 // 3. Any template referencing types above (e.g. std::vector<size_t>)
86 template <class P> 100 template <class P>
87 static inline void WriteParam(base::Pickle* m, const P& p) { 101 static inline void WriteParam(base::Pickle* m, const P& p) {
88 typedef typename SimilarTypeTraits<P>::Type Type; 102 typedef typename SimilarTypeTraits<P>::Type Type;
89 ParamTraits<Type>::Write(m, static_cast<const Type& >(p)); 103 ParamTraits<Type>::Write(m, static_cast<const Type& >(p));
90 } 104 }
91 105
92 template <class P> 106 template <class P>
93 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m, 107 static inline bool WARN_UNUSED_RESULT ReadParam(const base::Pickle* m,
94 base::PickleIterator* iter, 108 base::PickleIterator* iter,
95 P* p) { 109 P* p) {
(...skipping 989 matching lines...) Expand 10 before | Expand all | Expand 10 after
1085 template <class ReplyParamType> 1099 template <class ReplyParamType>
1086 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params, 1100 inline void LogReplyParamsToMessage(const ReplyParamType& reply_params,
1087 const Message* msg) {} 1101 const Message* msg) {}
1088 1102
1089 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {} 1103 inline void ConnectMessageAndReply(const Message* msg, Message* reply) {}
1090 #endif 1104 #endif
1091 1105
1092 } // namespace IPC 1106 } // namespace IPC
1093 1107
1094 #endif // IPC_IPC_MESSAGE_UTILS_H_ 1108 #endif // IPC_IPC_MESSAGE_UTILS_H_
OLDNEW
« no previous file with comments | « ipc/ipc_message_macros.h ('k') | tools/clang/plugins/CMakeLists.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698