OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2009, Google Inc. | 2 * Copyright 2009, Google Inc. |
3 * All rights reserved. | 3 * All rights reserved. |
4 * | 4 * |
5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
7 * met: | 7 * met: |
8 * | 8 * |
9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
67 parse_error::ParseError CommandParser::ProcessCommand() { | 67 parse_error::ParseError CommandParser::ProcessCommand() { |
68 CommandBufferOffset get = get_; | 68 CommandBufferOffset get = get_; |
69 if (get == put_) return parse_error::kParseNoError; | 69 if (get == put_) return parse_error::kParseNoError; |
70 | 70 |
71 CommandHeader header = buffer_[get].value_header; | 71 CommandHeader header = buffer_[get].value_header; |
72 if (header.size == 0) { | 72 if (header.size == 0) { |
73 DLOG(INFO) << "Error: zero sized command in command buffer"; | 73 DLOG(INFO) << "Error: zero sized command in command buffer"; |
74 return parse_error::kParseInvalidSize; | 74 return parse_error::kParseInvalidSize; |
75 } | 75 } |
76 | 76 |
77 if (header.size + get > entry_count_) { | 77 if (static_cast<size_t>(header.size + get) > entry_count_) { |
78 DLOG(INFO) << "Error: get offset out of bounds"; | 78 DLOG(INFO) << "Error: get offset out of bounds"; |
79 return parse_error::kParseOutOfBounds; | 79 return parse_error::kParseOutOfBounds; |
80 } | 80 } |
81 | 81 |
82 parse_error::ParseError result = handler_->DoCommand( | 82 parse_error::ParseError result = handler_->DoCommand( |
83 header.command, header.size - 1, buffer_ + get); | 83 header.command, header.size - 1, buffer_ + get); |
84 // TODO(gman): If you want to log errors this is the best place to catch them. | 84 // TODO(gman): If you want to log errors this is the best place to catch them. |
85 // It seems like we need an official way to turn on a debug mode and | 85 // It seems like we need an official way to turn on a debug mode and |
86 // get these errors. | 86 // get these errors. |
87 if (result != parse_error::kParseNoError) { | 87 if (result != parse_error::kParseNoError) { |
(...skipping 13 matching lines...) Expand all Loading... |
101 // is encountered. | 101 // is encountered. |
102 parse_error::ParseError CommandParser::ProcessAllCommands() { | 102 parse_error::ParseError CommandParser::ProcessAllCommands() { |
103 while (!IsEmpty()) { | 103 while (!IsEmpty()) { |
104 parse_error::ParseError error = ProcessCommand(); | 104 parse_error::ParseError error = ProcessCommand(); |
105 if (error) return error; | 105 if (error) return error; |
106 } | 106 } |
107 return parse_error::kParseNoError; | 107 return parse_error::kParseNoError; |
108 } | 108 } |
109 | 109 |
110 } // namespace command_buffer | 110 } // namespace command_buffer |
OLD | NEW |