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

Side by Side Diff: tools/ipc_fuzzer/message_lib/message_file_reader.cc

Issue 1549203002: Switch to standard integer types in tools/. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 #include <limits.h> 5 #include <limits.h>
6 #include <stddef.h>
7 #include <stdint.h>
6 8
7 #include "base/files/file_path.h" 9 #include "base/files/file_path.h"
8 #include "base/files/memory_mapped_file.h" 10 #include "base/files/memory_mapped_file.h"
9 #include "base/logging.h" 11 #include "base/logging.h"
12 #include "base/macros.h"
10 #include "base/strings/string_piece.h" 13 #include "base/strings/string_piece.h"
11 #include "ipc/ipc_message.h" 14 #include "ipc/ipc_message.h"
12 #include "tools/ipc_fuzzer/message_lib/message_cracker.h" 15 #include "tools/ipc_fuzzer/message_lib/message_cracker.h"
13 #include "tools/ipc_fuzzer/message_lib/message_file.h" 16 #include "tools/ipc_fuzzer/message_lib/message_file.h"
14 #include "tools/ipc_fuzzer/message_lib/message_file_format.h" 17 #include "tools/ipc_fuzzer/message_lib/message_file_format.h"
15 #include "tools/ipc_fuzzer/message_lib/message_names.h" 18 #include "tools/ipc_fuzzer/message_lib/message_names.h"
16 19
17 namespace ipc_fuzzer { 20 namespace ipc_fuzzer {
18 21
19 namespace { 22 namespace {
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 return false; 167 return false;
165 } 168 }
166 name_map_.Add(entry->type, std::string(string_table_.data() + offset)); 169 name_map_.Add(entry->type, std::string(string_table_.data() + offset));
167 } 170 }
168 return true; 171 return true;
169 } 172 }
170 173
171 bool Reader::RemoveUnknownMessages() { 174 bool Reader::RemoveUnknownMessages() {
172 MessageVector::iterator it = messages_->begin(); 175 MessageVector::iterator it = messages_->begin();
173 while (it != messages_->end()) { 176 while (it != messages_->end()) {
174 uint32 type = (*it)->type(); 177 uint32_t type = (*it)->type();
175 if (!name_map_.TypeExists(type)) { 178 if (!name_map_.TypeExists(type)) {
176 LOG(ERROR) << "Missing name table entry for type " << type; 179 LOG(ERROR) << "Missing name table entry for type " << type;
177 return false; 180 return false;
178 } 181 }
179 const std::string& name = name_map_.TypeToName(type); 182 const std::string& name = name_map_.TypeToName(type);
180 if (!MessageNames::GetInstance()->NameExists(name)) { 183 if (!MessageNames::GetInstance()->NameExists(name)) {
181 LOG(WARNING) << "Unknown message " << name; 184 LOG(WARNING) << "Unknown message " << name;
182 it = messages_->erase(it); 185 it = messages_->erase(it);
183 } else { 186 } else {
184 ++it; 187 ++it;
185 } 188 }
186 } 189 }
187 return true; 190 return true;
188 } 191 }
189 192
190 // Message types are based on line numbers, so a minor edit of *_messages.h 193 // Message types are based on line numbers, so a minor edit of *_messages.h
191 // changes the types of messages in that file. The types are fixed here to 194 // changes the types of messages in that file. The types are fixed here to
192 // increase the lifetime of message files. This is only a partial fix because 195 // increase the lifetime of message files. This is only a partial fix because
193 // message arguments and structure layouts can change as well. 196 // message arguments and structure layouts can change as well.
194 void Reader::FixMessageTypes() { 197 void Reader::FixMessageTypes() {
195 for (MessageVector::iterator it = messages_->begin(); 198 for (MessageVector::iterator it = messages_->begin();
196 it != messages_->end(); ++it) { 199 it != messages_->end(); ++it) {
197 uint32 type = (*it)->type(); 200 uint32_t type = (*it)->type();
198 const std::string& name = name_map_.TypeToName(type); 201 const std::string& name = name_map_.TypeToName(type);
199 uint32 correct_type = MessageNames::GetInstance()->NameToType(name); 202 uint32_t correct_type = MessageNames::GetInstance()->NameToType(name);
200 if (type != correct_type) 203 if (type != correct_type)
201 MessageCracker::SetMessageType(*it, correct_type); 204 MessageCracker::SetMessageType(*it, correct_type);
202 } 205 }
203 } 206 }
204 207
205 bool Reader::Read(MessageVector* messages) { 208 bool Reader::Read(MessageVector* messages) {
206 messages_ = messages; 209 messages_ = messages;
207 210
208 if (!MapFile()) 211 if (!MapFile())
209 return false; 212 return false;
(...skipping 13 matching lines...) Expand all
223 } 226 }
224 227
225 } // namespace 228 } // namespace
226 229
227 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) { 230 bool MessageFile::Read(const base::FilePath& path, MessageVector* messages) {
228 Reader reader(path); 231 Reader reader(path);
229 return reader.Read(messages); 232 return reader.Read(messages);
230 } 233 }
231 234
232 } // namespace ipc_fuzzer 235 } // namespace ipc_fuzzer
OLDNEW
« no previous file with comments | « tools/ipc_fuzzer/message_lib/message_file_format.h ('k') | tools/ipc_fuzzer/message_lib/message_file_writer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698