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

Side by Side Diff: url/url_canon_ip.cc

Issue 413023002: use a gcc version check in 4.9 warning workaround (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: simplify ifdef, pop properly Created 6 years, 5 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 | Annotate | Revision Log
« 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 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 "url/url_canon_ip.h" 5 #include "url/url_canon_ip.h"
6 6
7 #include <stdlib.h> 7 #include <stdlib.h>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/logging.h" 10 #include "base/logging.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 // First, process all components but the last, while making sure each fits 198 // First, process all components but the last, while making sure each fits
199 // within an 8-bit field. 199 // within an 8-bit field.
200 for (int i = 0; i < existing_components - 1; i++) { 200 for (int i = 0; i < existing_components - 1; i++) {
201 if (component_values[i] > kuint8max) 201 if (component_values[i] > kuint8max)
202 return CanonHostInfo::BROKEN; 202 return CanonHostInfo::BROKEN;
203 address[i] = static_cast<unsigned char>(component_values[i]); 203 address[i] = static_cast<unsigned char>(component_values[i]);
204 } 204 }
205 205
206 // Next, consume the last component to fill in the remaining bytes. 206 // Next, consume the last component to fill in the remaining bytes.
207 // Work around a gcc 4.9 bug. crbug.com/392872 207 // Work around a gcc 4.9 bug. crbug.com/392872
208 #if defined(__GNUC__) 208 #if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4)
209 #pragma GCC diagnostic push 209 #pragma GCC diagnostic push
210 #pragma GCC diagnostic ignored "-Warray-bounds" 210 #pragma GCC diagnostic ignored "-Warray-bounds"
211 #endif 211 #endif
212 uint32 last_value = component_values[existing_components - 1]; 212 uint32 last_value = component_values[existing_components - 1];
213 #if defined(__GNUC__) 213 #if ((__GNUC__ == 4 && __GNUC_MINOR__ >= 9) || __GNUC__ > 4)
214 #pragma GCC diagnostic pop 214 #pragma GCC diagnostic pop
215 #endif 215 #endif
216 for (int i = 3; i >= existing_components - 1; i--) { 216 for (int i = 3; i >= existing_components - 1; i--) {
217 address[i] = static_cast<unsigned char>(last_value); 217 address[i] = static_cast<unsigned char>(last_value);
218 last_value >>= 8; 218 last_value >>= 8;
219 } 219 }
220 220
221 // If the last component has residual bits, report overflow. 221 // If the last component has residual bits, report overflow.
222 if (last_value != 0) 222 if (last_value != 0)
223 return CanonHostInfo::BROKEN; 223 return CanonHostInfo::BROKEN;
(...skipping 476 matching lines...) Expand 10 before | Expand all | Expand 10 after
700 return DoIPv6AddressToNumber<char, unsigned char>(spec, host, address); 700 return DoIPv6AddressToNumber<char, unsigned char>(spec, host, address);
701 } 701 }
702 702
703 bool IPv6AddressToNumber(const base::char16* spec, 703 bool IPv6AddressToNumber(const base::char16* spec,
704 const Component& host, 704 const Component& host,
705 unsigned char address[16]) { 705 unsigned char address[16]) {
706 return DoIPv6AddressToNumber<base::char16, base::char16>(spec, host, address); 706 return DoIPv6AddressToNumber<base::char16, base::char16>(spec, host, address);
707 } 707 }
708 708
709 } // namespace url 709 } // namespace url
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