vboot_reference: Rename *_SECTOR to *_SECTORS

This CL renames GPT_PMBR_SECTOR to GPT_PMBR_SECTORS and GPT_HEADER_SECTOR to
GPT_HEADER_SECTORS to better indicate that these are constants for sizes, not
location.

BRANCH=None
BUG=None
TEST=unittest

Change-Id: I26ed6d45d77dcb1eb714135edbb9e4124b54e953
Reviewed-on: https://chromium-review.googlesource.com/214830
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Tested-by: Nam Nguyen <namnguyen@chromium.org>
Commit-Queue: Nam Nguyen <namnguyen@chromium.org>
diff --git a/cgpt/cgpt_common.c b/cgpt/cgpt_common.c
index 44652a3..9eb9950 100644
--- a/cgpt/cgpt_common.c
+++ b/cgpt/cgpt_common.c
@@ -309,13 +309,13 @@
 
   // Read the data.
   if (CGPT_OK != Load(drive, &drive->gpt.primary_header,
-                      GPT_PMBR_SECTOR,
-                      drive->gpt.sector_bytes, GPT_HEADER_SECTOR)) {
+                      GPT_PMBR_SECTORS,
+                      drive->gpt.sector_bytes, GPT_HEADER_SECTORS)) {
     return -1;
   }
   if (CGPT_OK != Load(drive, &drive->gpt.secondary_header,
-                      drive->gpt.drive_sectors - GPT_PMBR_SECTOR,
-                      drive->gpt.sector_bytes, GPT_HEADER_SECTOR)) {
+                      drive->gpt.drive_sectors - GPT_PMBR_SECTORS,
+                      drive->gpt.sector_bytes, GPT_HEADER_SECTORS)) {
     return -1;
   }
   GptHeader* primary_header = (GptHeader*)drive->gpt.primary_header;
@@ -337,8 +337,8 @@
   int errors = 0;
   if (drive->gpt.modified & GPT_MODIFIED_HEADER1) {
     if (CGPT_OK != Save(drive, drive->gpt.primary_header,
-                        GPT_PMBR_SECTOR,
-                        drive->gpt.sector_bytes, GPT_HEADER_SECTOR)) {
+                        GPT_PMBR_SECTORS,
+                        drive->gpt.sector_bytes, GPT_HEADER_SECTORS)) {
       errors++;
       Error("Cannot write primary header: %s\n", strerror(errno));
     }
@@ -346,8 +346,8 @@
 
   if (drive->gpt.modified & GPT_MODIFIED_HEADER2) {
     if(CGPT_OK != Save(drive, drive->gpt.secondary_header,
-                       drive->gpt.drive_sectors - GPT_PMBR_SECTOR,
-                       drive->gpt.sector_bytes, GPT_HEADER_SECTOR)) {
+                       drive->gpt.drive_sectors - GPT_PMBR_SECTORS,
+                       drive->gpt.sector_bytes, GPT_HEADER_SECTORS)) {
       errors++;
       Error("Cannot write secondary header: %s\n", strerror(errno));
     }
@@ -1155,10 +1155,10 @@
     return GPT_MODIFIED_HEADER2;
   } else if (valid_headers == MASK_SECONDARY) {
     memcpy(primary_header, secondary_header, sizeof(GptHeader));
-    primary_header->my_lba = GPT_PMBR_SECTOR;  /* the second sector on drive */
+    primary_header->my_lba = GPT_PMBR_SECTORS;  /* the second sector on drive */
     primary_header->alternate_lba = secondary_header->my_lba;
     /* TODO (namnguyen): Preserve (header, entries) padding space. */
-    primary_header->entries_lba = primary_header->my_lba + GPT_HEADER_SECTOR;
+    primary_header->entries_lba = primary_header->my_lba + GPT_HEADER_SECTORS;
     return GPT_MODIFIED_HEADER1;
   }
 
diff --git a/cgpt/cgpt_create.c b/cgpt/cgpt_create.c
index c9134da..cec6077 100644
--- a/cgpt/cgpt_create.c
+++ b/cgpt/cgpt_create.c
@@ -12,9 +12,9 @@
 static int GptCreate(struct drive *drive, CgptCreateParams *params) {
   // Erase the data
   memset(drive->gpt.primary_header, 0,
-         drive->gpt.sector_bytes * GPT_HEADER_SECTOR);
+         drive->gpt.sector_bytes * GPT_HEADER_SECTORS);
   memset(drive->gpt.secondary_header, 0,
-         drive->gpt.sector_bytes * GPT_HEADER_SECTOR);
+         drive->gpt.sector_bytes * GPT_HEADER_SECTORS);
   memset(drive->gpt.primary_entries, 0,
          drive->gpt.sector_bytes * GPT_ENTRIES_SECTORS);
   memset(drive->gpt.secondary_entries, 0,
@@ -29,11 +29,11 @@
     memcpy(h->signature, GPT_HEADER_SIGNATURE, GPT_HEADER_SIGNATURE_SIZE);
     h->revision = GPT_HEADER_REVISION;
     h->size = sizeof(GptHeader);
-    h->my_lba = GPT_PMBR_SECTOR;  /* The second sector on drive. */
-    h->alternate_lba = drive->gpt.drive_sectors - GPT_HEADER_SECTOR;
-    h->entries_lba = h->my_lba + GPT_HEADER_SECTOR + params->padding;
+    h->my_lba = GPT_PMBR_SECTORS;  /* The second sector on drive. */
+    h->alternate_lba = drive->gpt.drive_sectors - GPT_HEADER_SECTORS;
+    h->entries_lba = h->my_lba + GPT_HEADER_SECTORS + params->padding;
     h->first_usable_lba = h->entries_lba + GPT_ENTRIES_SECTORS;
-    h->last_usable_lba = (drive->gpt.drive_sectors - GPT_HEADER_SECTOR -
+    h->last_usable_lba = (drive->gpt.drive_sectors - GPT_HEADER_SECTORS -
                           GPT_ENTRIES_SECTORS - 1);
     if (CGPT_OK != GenerateGuid(&h->disk_uuid)) {
       Error("Unable to generate new GUID.\n");
diff --git a/cgpt/cgpt_show.c b/cgpt/cgpt_show.c
index 3603770..4788bfd 100644
--- a/cgpt/cgpt_show.c
+++ b/cgpt/cgpt_show.c
@@ -394,14 +394,14 @@
     printf(TITLE_FMT, "start", "size", "part", "contents");
     char buf[256];                      // buffer for formatted PMBR content
     PMBRToStr(&drive->pmbr, buf, sizeof(buf)); // will exit if buf is too small
-    printf(GPT_FMT, 0, GPT_PMBR_SECTOR, "", buf);
+    printf(GPT_FMT, 0, GPT_PMBR_SECTORS, "", buf);
 
     if (drive->gpt.valid_headers & MASK_PRIMARY) {
-      printf(GPT_FMT, (int)GPT_PMBR_SECTOR,
-             (int)GPT_HEADER_SECTOR, "", "Pri GPT header");
+      printf(GPT_FMT, (int)GPT_PMBR_SECTORS,
+             (int)GPT_HEADER_SECTORS, "", "Pri GPT header");
     } else {
-      printf(GPT_FMT, (int)GPT_PMBR_SECTOR,
-             (int)GPT_HEADER_SECTOR, "INVALID", "Pri GPT header");
+      printf(GPT_FMT, (int)GPT_PMBR_SECTORS,
+             (int)GPT_HEADER_SECTORS, "INVALID", "Pri GPT header");
     }
 
     if (params->debug ||
@@ -445,11 +445,11 @@
     }
 
     if (drive->gpt.valid_headers & MASK_SECONDARY)
-      printf(GPT_FMT, (int)(drive->gpt.drive_sectors - GPT_HEADER_SECTOR),
-             (int)GPT_HEADER_SECTOR, "", "Sec GPT header");
+      printf(GPT_FMT, (int)(drive->gpt.drive_sectors - GPT_HEADER_SECTORS),
+             (int)GPT_HEADER_SECTORS, "", "Sec GPT header");
     else
-      printf(GPT_FMT, (int)GPT_PMBR_SECTOR,
-             (int)GPT_HEADER_SECTOR, "INVALID", "Sec GPT header");
+      printf(GPT_FMT, (int)GPT_PMBR_SECTORS,
+             (int)GPT_HEADER_SECTORS, "INVALID", "Sec GPT header");
     /* We show secondary header if any of following is true:
      *   1. in debug mode.
      *   2. only secondary is valid.
diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c
index 510a11f..38ca7d9 100644
--- a/firmware/lib/cgptlib/cgptlib_internal.c
+++ b/firmware/lib/cgptlib/cgptlib_internal.c
@@ -88,12 +88,12 @@
 	 * secondary is at the end of the drive, preceded by its entries.
 	 */
 	if (is_secondary) {
-		if (h->my_lba != drive_sectors - GPT_HEADER_SECTOR)
+		if (h->my_lba != drive_sectors - GPT_HEADER_SECTORS)
 			return 1;
 		if (h->entries_lba != h->my_lba - GPT_ENTRIES_SECTORS)
 			return 1;
 	} else {
-		if (h->my_lba != GPT_PMBR_SECTOR)
+		if (h->my_lba != GPT_PMBR_SECTORS)
 			return 1;
 		if (h->entries_lba < h->my_lba + 1)
 			return 1;
@@ -296,8 +296,8 @@
 	if (MASK_PRIMARY == gpt->valid_headers) {
 		/* Primary is good, secondary is bad */
 		Memcpy(header2, header1, sizeof(GptHeader));
-		header2->my_lba = gpt->drive_sectors - GPT_HEADER_SECTOR;
-		header2->alternate_lba = GPT_PMBR_SECTOR;  /* Second sector. */
+		header2->my_lba = gpt->drive_sectors - GPT_HEADER_SECTORS;
+		header2->alternate_lba = GPT_PMBR_SECTORS;  /* Second sector. */
 		header2->entries_lba = header2->my_lba - GPT_ENTRIES_SECTORS;
 		header2->header_crc32 = HeaderCrc(header2);
 		gpt->modified |= GPT_MODIFIED_HEADER2;
@@ -305,8 +305,8 @@
 	else if (MASK_SECONDARY == gpt->valid_headers) {
 		/* Secondary is good, primary is bad */
 		Memcpy(header1, header2, sizeof(GptHeader));
-		header1->my_lba = GPT_PMBR_SECTOR;  /* Second sector. */
-		header1->alternate_lba = gpt->drive_sectors - GPT_HEADER_SECTOR;
+		header1->my_lba = GPT_PMBR_SECTORS;  /* Second sector. */
+		header1->alternate_lba = gpt->drive_sectors - GPT_HEADER_SECTORS;
 		/* TODO (namnguyen): Preserve (header, entries) padding. */
 		header1->entries_lba = header1->my_lba + 1;
 		header1->header_crc32 = HeaderCrc(header1);
diff --git a/firmware/lib/cgptlib/include/cgptlib_internal.h b/firmware/lib/cgptlib/include/cgptlib_internal.h
index b269141..e9e63ca 100644
--- a/firmware/lib/cgptlib/include/cgptlib_internal.h
+++ b/firmware/lib/cgptlib/include/cgptlib_internal.h
@@ -55,8 +55,8 @@
 #define MAX_NUMBER_OF_ENTRIES 512
 
 /* Defines GPT sizes */
-#define GPT_PMBR_SECTOR 1  /* size (in sectors) of PMBR */
-#define GPT_HEADER_SECTOR 1
+#define GPT_PMBR_SECTORS 1  /* size (in sectors) of PMBR */
+#define GPT_HEADER_SECTORS 1
 /*
  * Entries sectors assumes sector size if 512 bytes; then (TOTAL_ENTRIES_SIZE /
  * 512) = 32
diff --git a/firmware/lib/vboot_kernel.c b/firmware/lib/vboot_kernel.c
index 99bf93b..df32fc0 100644
--- a/firmware/lib/vboot_kernel.c
+++ b/firmware/lib/vboot_kernel.c
@@ -90,7 +90,7 @@
 	 * TODO(namnguyen): Preserve padding between primary GPT header and
 	 * its entries.
 	 */
-	uint64_t entries_lba = GPT_PMBR_SECTOR + GPT_HEADER_SECTOR;
+	uint64_t entries_lba = GPT_PMBR_SECTORS + GPT_HEADER_SECTORS;
 	if (gptdata->primary_header) {
 		GptHeader *h = (GptHeader *)(gptdata->primary_header);
 		entries_lba = h->entries_lba;
@@ -133,7 +133,7 @@
 	}
 
 	entries_lba = (gptdata->drive_sectors - entries_sectors -
-		GPT_HEADER_SECTOR);
+		GPT_HEADER_SECTORS);
 	if (gptdata->secondary_header) {
 		GptHeader *h = (GptHeader *)(gptdata->secondary_header);
 		entries_lba = h->entries_lba;
diff --git a/tests/cgptlib_test.c b/tests/cgptlib_test.c
index 5d46692..21334a5 100644
--- a/tests/cgptlib_test.c
+++ b/tests/cgptlib_test.c
@@ -317,7 +317,7 @@
 		{520, DEFAULT_DRIVE_SECTORS, GPT_ERROR_INVALID_SECTOR_SIZE},
 		{512, 0, GPT_ERROR_INVALID_SECTOR_NUMBER},
 		{512, 66, GPT_ERROR_INVALID_SECTOR_NUMBER},
-		{512, GPT_PMBR_SECTOR + GPT_HEADER_SECTOR * 2 +
+		{512, GPT_PMBR_SECTORS + GPT_HEADER_SECTORS * 2 +
 		 GPT_ENTRIES_SECTORS * 2, GPT_SUCCESS},
 		{4096, DEFAULT_DRIVE_SECTORS, GPT_ERROR_INVALID_SECTOR_SIZE},
 	};