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

Side by Side Diff: vboot_firmware/lib/cgptlib/cgptlib_internal.c

Issue 2829004: More code cleanup (Closed) Base URL: ssh://gitrw.chromium.org/vboot_reference.git
Patch Set: rebase Created 10 years, 6 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 | « vboot_firmware/include/load_firmware_fw.h ('k') | vboot_firmware/lib/include/vboot_struct.h » ('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 (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS 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 5
6 #include "cgptlib.h" 6 #include "cgptlib.h"
7 #include "cgptlib_internal.h" 7 #include "cgptlib_internal.h"
8 #include "crc32.h" 8 #include "crc32.h"
9 #include "gpt.h" 9 #include "gpt.h"
10 #include "utility.h" 10 #include "utility.h"
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
95 if (h->last_usable_lba >= drive_sectors - 1 - GPT_ENTRIES_SECTORS) 95 if (h->last_usable_lba >= drive_sectors - 1 - GPT_ENTRIES_SECTORS)
96 return 1; 96 return 1;
97 if (h->first_usable_lba > h->last_usable_lba) 97 if (h->first_usable_lba > h->last_usable_lba)
98 return 1; 98 return 1;
99 99
100 /* Success */ 100 /* Success */
101 return 0; 101 return 0;
102 } 102 }
103 103
104 104
105 /* Return 1 if the entry is unused, 0 if it is used. */ 105 /* Return non-zero if the entry is unused, 0 if it is used. */
106 int IsUnusedEntry(const GptEntry* e) { 106 int IsUnusedEntry(const GptEntry* e) {
107 static Guid zero = {{{0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}}; 107 static Guid zero = {{{0, 0, 0, 0, 0, {0, 0, 0, 0, 0, 0}}}};
108 return (Memcmp(&zero, (const uint8_t*)(&e->type), sizeof(zero)) ? 0 : 1); 108 return !Memcmp(&zero, (const uint8_t*)(&e->type), sizeof(zero));
109 } 109 }
110 110
111 /* Returns 1 if the entry is a Chrome OS kernel partition, else 0. */ 111 /* Returns non-zero if the entry is a Chrome OS kernel partition, else 0. */
112 int IsKernelEntry(const GptEntry* e) { 112 int IsKernelEntry(const GptEntry* e) {
113 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; 113 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL;
114 return (Memcmp(&e->type, &chromeos_kernel, sizeof(Guid)) ? 0 : 1); 114 return !Memcmp(&e->type, &chromeos_kernel, sizeof(Guid));
115 } 115 }
116 116
117 117
118 int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors) { 118 int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors) {
119 119
120 GptEntry* entry; 120 GptEntry* entry;
121 uint32_t crc32; 121 uint32_t crc32;
122 int i; 122 int i;
123 123
124 /* Check CRC before examining entries. */ 124 /* Check CRC before examining entries. */
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 e->attributes |= ((uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET) & 339 e->attributes |= ((uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET) &
340 CGPT_ATTRIBUTE_PRIORITY_MASK; 340 CGPT_ATTRIBUTE_PRIORITY_MASK;
341 } 341 }
342 342
343 343
344 void SetEntryTries(GptEntry* e, int tries) { 344 void SetEntryTries(GptEntry* e, int tries) {
345 e->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK; 345 e->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK;
346 e->attributes |= ((uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & 346 e->attributes |= ((uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET) &
347 CGPT_ATTRIBUTE_TRIES_MASK; 347 CGPT_ATTRIBUTE_TRIES_MASK;
348 } 348 }
OLDNEW
« no previous file with comments | « vboot_firmware/include/load_firmware_fw.h ('k') | vboot_firmware/lib/include/vboot_struct.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698