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

Side by Side Diff: tools/android/file_poller/file_poller.cc

Issue 1551313002: Enable -Wformat in linux, android, chromeos, cast builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase 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 | « build/config/compiler/BUILD.gn ('k') | tools/android/memconsumer/memconsumer_hook.cc » ('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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 // When run with 2 or more arguments the file_poller tool will open a port on 5 // When run with 2 or more arguments the file_poller tool will open a port on
6 // the device, print it on its standard output and then start collect file 6 // the device, print it on its standard output and then start collect file
7 // contents. The first argument is the polling rate in Hz, and the following 7 // contents. The first argument is the polling rate in Hz, and the following
8 // arguments are file to poll. 8 // arguments are file to poll.
9 // When run with the port of an already running file_poller, the tool will 9 // When run with the port of an already running file_poller, the tool will
10 // contact the first instance, retrieve the sample and print those on its 10 // contact the first instance, retrieve the sample and print those on its
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 int n = transfer_to_buffer(fd_in, buffer, sizeof(buffer)); 81 int n = transfer_to_buffer(fd_in, buffer, sizeof(buffer));
82 safe_write(fd_out, buffer, n - 1); 82 safe_write(fd_out, buffer, n - 1);
83 safe_write(fd_out, last ? "\n" : " ", 1); 83 safe_write(fd_out, last ? "\n" : " ", 1);
84 } 84 }
85 85
86 // Acquire a sample and save it to the given file descriptor. 86 // Acquire a sample and save it to the given file descriptor.
87 void acquire_sample(int fd, const Context& context) { 87 void acquire_sample(int fd, const Context& context) {
88 struct timeval tv; 88 struct timeval tv;
89 gettimeofday(&tv, NULL); 89 gettimeofday(&tv, NULL);
90 char buffer[1024]; 90 char buffer[1024];
91 int n = snprintf(buffer, sizeof(buffer), "%d.%06d ", tv.tv_sec, tv.tv_usec); 91 int n = snprintf(buffer, sizeof(buffer), "%ld.%06ld ", tv.tv_sec, tv.tv_usec);
92 safe_write(fd, buffer, n); 92 safe_write(fd, buffer, n);
93 93
94 for (int i = 0; i < context.nb_files; ++i) 94 for (int i = 0; i < context.nb_files; ++i)
95 transfer_measurement(context.file_fds[i], fd, i == (context.nb_files - 1)); 95 transfer_measurement(context.file_fds[i], fd, i == (context.nb_files - 1));
96 } 96 }
97 97
98 void poll_content(const Context& context) { 98 void poll_content(const Context& context) {
99 // Create and bind the socket so that the port can be written to stdout. 99 // Create and bind the socket so that the port can be written to stdout.
100 int sockfd = socket(AF_INET, SOCK_STREAM, 0); 100 int sockfd = socket(AF_INET, SOCK_STREAM, 0);
101 struct sockaddr_in socket_info; 101 struct sockaddr_in socket_info;
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
199 Context context; 199 Context context;
200 context.poll_rate = atoi(argv[1]); 200 context.poll_rate = atoi(argv[1]);
201 context.nb_files = argc - 2; 201 context.nb_files = argc - 2;
202 context.file_fds = new int[context.nb_files]; 202 context.file_fds = new int[context.nb_files];
203 for (int i = 2; i < argc; ++i) 203 for (int i = 2; i < argc; ++i)
204 context.file_fds[i - 2] = checked_open(argv[i]); 204 context.file_fds[i - 2] = checked_open(argv[i]);
205 poll_content(context); 205 poll_content(context);
206 } 206 }
207 return EXIT_SUCCESS; 207 return EXIT_SUCCESS;
208 } 208 }
OLDNEW
« no previous file with comments | « build/config/compiler/BUILD.gn ('k') | tools/android/memconsumer/memconsumer_hook.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698