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

Side by Side Diff: tools/battor_agent/battor_agent.cc

Issue 1577983004: Avoid VS 2015 truncation warning (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@vs2015_package
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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "tools/battor_agent/battor_agent.h" 5 #include "tools/battor_agent/battor_agent.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/thread_task_runner_handle.h" 8 #include "base/thread_task_runner_handle.h"
9 #include "tools/battor_agent/battor_connection_impl.h" 9 #include "tools/battor_agent/battor_connection_impl.h"
10 10
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 return false; 67 return false;
68 68
69 // The first bytes in the frame contain the frame header. 69 // The first bytes in the frame contain the frame header.
70 const char* frame_ptr = reinterpret_cast<const char*>(msg.data()); 70 const char* frame_ptr = reinterpret_cast<const char*>(msg.data());
71 memcpy(frame_header, frame_ptr, sizeof(BattOrFrameHeader)); 71 memcpy(frame_header, frame_ptr, sizeof(BattOrFrameHeader));
72 frame_ptr += sizeof(BattOrFrameHeader); 72 frame_ptr += sizeof(BattOrFrameHeader);
73 73
74 // The remaining bytes in the frame contain an array of raw samples. 74 // The remaining bytes in the frame contain an array of raw samples.
75 // Therefore, the number of samples in the frame should correspond to number 75 // Therefore, the number of samples in the frame should correspond to number
76 // of total bytes remaining in the frame. 76 // of total bytes remaining in the frame.
77 uint8_t samples_in_frame = 77 size_t samples_in_frame =
78 (msg.size() - sizeof(BattOrFrameHeader)) / sizeof(RawBattOrSample); 78 (msg.size() - sizeof(BattOrFrameHeader)) / sizeof(RawBattOrSample);
79 79
80 if (samples_in_frame != frame_header->length) 80 if (samples_in_frame != frame_header->length)
81 return false; 81 return false;
82 82
83 samples->resize(samples_in_frame); 83 samples->resize(samples_in_frame);
84 memcpy(samples->data(), frame_ptr, 84 memcpy(samples->data(), frame_ptr,
85 samples_in_frame * sizeof(RawBattOrSample)); 85 samples_in_frame * sizeof(RawBattOrSample));
86 86
87 return true; 87 return true;
(...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 } 398 }
399 399
400 last_action_ = Action::INVALID; 400 last_action_ = Action::INVALID;
401 command_ = Command::INVALID; 401 command_ = Command::INVALID;
402 battor_eeprom_.reset(); 402 battor_eeprom_.reset();
403 calibration_frame_.clear(); 403 calibration_frame_.clear();
404 samples_.clear(); 404 samples_.clear();
405 } 405 }
406 406
407 } // namespace battor 407 } // namespace battor
OLDNEW
« 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