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

Unified Diff: media/midi/usb_midi_output_stream.cc

Issue 694733002: [WebMIDI] Fix code style to suppress a static analysis error. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: media/midi/usb_midi_output_stream.cc
diff --git a/media/midi/usb_midi_output_stream.cc b/media/midi/usb_midi_output_stream.cc
index 1aef2824676faafcc67d15e1a8f5e1f2aa59df02..4e53291c6bf427b906b0fc95033b1fb106f8e30e 100644
--- a/media/midi/usb_midi_output_stream.cc
+++ b/media/midi/usb_midi_output_stream.cc
@@ -119,12 +119,15 @@ bool UsbMidiOutputStream::PushSysCommonMessage(
std::vector<uint8>* data_to_send) {
size_t index = *current;
uint8 first_byte = Get(data, index);
+ // There are only 6 message types (0xf1 - 0xf7), so we have the size table of
Takashi Toyoshima 2014/10/31 07:13:37 Is this place intended? It sounds like a descripti
yhirano 2014/10/31 07:42:54 Done.
+ // size 8.
DCHECK_LE(0xf1, first_byte);
DCHECK_LE(first_byte, 0xf7);
+ DCHECK_EQ(0xf0, first_byte & 0xf8);
const size_t message_size_table[8] = {
0, 2, 3, 2, 1, 1, 1, 0,
};
- size_t message_size = message_size_table[first_byte & 0x0f];
+ size_t message_size = message_size_table[first_byte & 0x07];
DCHECK_NE(0u, message_size);
DCHECK_LE(message_size, 3u);
@@ -161,13 +164,17 @@ bool UsbMidiOutputStream::PushChannelMessage(const std::vector<uint8>& data,
std::vector<uint8>* data_to_send) {
size_t index = *current;
uint8 first_byte = Get(data, index);
+
+ // There are only 7 message types (0x80 - 0xe0), so we have the size table
Takashi Toyoshima 2014/10/31 07:13:37 Same. Is this for message_size_table at line 172?
yhirano 2014/10/31 07:42:54 Done.
+ // of size 8.
DCHECK_LE(0x80, (first_byte & 0xf0));
DCHECK_LE((first_byte & 0xf0), 0xe0);
-
const size_t message_size_table[8] = {
3, 3, 3, 3, 2, 3, 3, 0,
};
uint8 code_index = first_byte >> 4;
+ DCHECK_LE(0x08, code_index);
+ DCHECK_LE(code_index, 0x0e);
size_t message_size = message_size_table[code_index & 0x7];
DCHECK_NE(0u, message_size);
DCHECK_LE(message_size, 3u);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698