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

Side by Side Diff: courgette/third_party/bsdiff_apply.cc

Issue 857153003: Use "static_assert" in lieu of "COMPILE_ASSERT" in courgete (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 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 | « courgette/encoded_program.cc ('k') | courgette/third_party/bsdiff_create.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 /*- 1 /*-
2 * Copyright 2003,2004 Colin Percival 2 * Copyright 2003,2004 Colin Percival
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 providing that the following conditions 6 * modification, are permitted providing that the following conditions
7 * are met: 7 * are met:
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 namespace courgette { 43 namespace courgette {
44 44
45 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) { 45 BSDiffStatus MBS_ReadHeader(SourceStream* stream, MBSPatchHeader* header) {
46 if (!stream->Read(header->tag, sizeof(header->tag))) return READ_ERROR; 46 if (!stream->Read(header->tag, sizeof(header->tag))) return READ_ERROR;
47 if (!stream->ReadVarint32(&header->slen)) return READ_ERROR; 47 if (!stream->ReadVarint32(&header->slen)) return READ_ERROR;
48 if (!stream->ReadVarint32(&header->scrc32)) return READ_ERROR; 48 if (!stream->ReadVarint32(&header->scrc32)) return READ_ERROR;
49 if (!stream->ReadVarint32(&header->dlen)) return READ_ERROR; 49 if (!stream->ReadVarint32(&header->dlen)) return READ_ERROR;
50 50
51 // The string will have a NUL terminator that we don't use, hence '-1'. 51 // The string will have a NUL terminator that we don't use, hence '-1'.
52 COMPILE_ASSERT(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header->tag), 52 static_assert(sizeof(MBS_PATCH_HEADER_TAG) - 1 == sizeof(header->tag),
53 MBS_PATCH_HEADER_TAG_must_match_header_field_size); 53 "MBS_PATCH_HEADER_TAG must match header field size");
54 if (memcmp(header->tag, MBS_PATCH_HEADER_TAG, 8) != 0) 54 if (memcmp(header->tag, MBS_PATCH_HEADER_TAG, 8) != 0)
55 return UNEXPECTED_ERROR; 55 return UNEXPECTED_ERROR;
56 56
57 return OK; 57 return OK;
58 } 58 }
59 59
60 BSDiffStatus MBS_ApplyPatch(const MBSPatchHeader *header, 60 BSDiffStatus MBS_ApplyPatch(const MBSPatchHeader *header,
61 SourceStream* patch_stream, 61 SourceStream* patch_stream,
62 const uint8* old_start, size_t old_size, 62 const uint8* old_start, size_t old_size,
63 SinkStream* new_stream) { 63 SinkStream* new_stream) {
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after
203 int written = base::WriteFile( 203 int written = base::WriteFile(
204 new_file_path, 204 new_file_path,
205 reinterpret_cast<const char*>(new_sink_stream.Buffer()), 205 reinterpret_cast<const char*>(new_sink_stream.Buffer()),
206 static_cast<int>(new_sink_stream.Length())); 206 static_cast<int>(new_sink_stream.Length()));
207 if (written != static_cast<int>(new_sink_stream.Length())) 207 if (written != static_cast<int>(new_sink_stream.Length()))
208 return WRITE_ERROR; 208 return WRITE_ERROR;
209 return OK; 209 return OK;
210 } 210 }
211 211
212 } // namespace 212 } // namespace
OLDNEW
« no previous file with comments | « courgette/encoded_program.cc ('k') | courgette/third_party/bsdiff_create.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698