You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by cc...@apache.org on 2016/11/10 22:38:19 UTC

[07/50] incubator-mynewt-newt git commit: newt - Rename a few mfg entities

newt - Rename a few mfg entities

Some of the names for mfg entities turned out to be confusing or
ambiguous.  This commite effects the following renames:

* raw section --> raw entry
* device section --> section


Project: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/commit/53574f43
Tree: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/tree/53574f43
Diff: http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/diff/53574f43

Branch: refs/heads/master
Commit: 53574f43914f4fa0b013e40a8557ea5bf215f8bd
Parents: 09bd4f9
Author: Christopher Collins <cc...@apache.org>
Authored: Wed Oct 26 09:12:05 2016 -0700
Committer: Christopher Collins <cc...@apache.org>
Committed: Wed Oct 26 09:15:33 2016 -0700

----------------------------------------------------------------------
 newt/mfg/create.go | 28 ++++++++++++++--------------
 newt/mfg/load.go   | 38 +++++++++++++++++++-------------------
 newt/mfg/meta.go   |  6 +++---
 newt/mfg/mfg.go    | 10 +++++-----
 4 files changed, 41 insertions(+), 41 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/create.go
----------------------------------------------------------------------
diff --git a/newt/mfg/create.go b/newt/mfg/create.go
index 0db4f16..5653b3a 100644
--- a/newt/mfg/create.go
+++ b/newt/mfg/create.go
@@ -101,8 +101,8 @@ func (mi *MfgImage) section0Size() int {
 		greatest = util.IntMax(greatest, image1Area.Offset+image1Area.Size)
 	}
 
-	for _, section := range mi.rawSections {
-		greatest = util.IntMax(greatest, section.offset+len(section.data))
+	for _, entry := range mi.rawEntries {
+		greatest = util.IntMax(greatest, entry.offset+len(entry.data))
 	}
 
 	return greatest
@@ -161,7 +161,7 @@ func createSectionHeader(deviceId int, offset int, size int) ([]byte, error) {
 }
 
 // @return						[section0blob, section1blob,...], hash, err
-func (mi *MfgImage) createDeviceSections(parts []mfgPart) (
+func (mi *MfgImage) createSections(parts []mfgPart) (
 	[][]byte, []byte, error) {
 
 	section0Data, hashOff, err := mi.section0Data(parts)
@@ -169,7 +169,7 @@ func (mi *MfgImage) createDeviceSections(parts []mfgPart) (
 		return nil, nil, err
 	}
 
-	// XXX: Append additional flash device sections.
+	// XXX: Append additional sections.
 
 	// Calculate manufacturing has.
 	sections := [][]byte{section0Data}
@@ -192,12 +192,12 @@ func areaNameFromImgIdx(imgIdx int) (string, error) {
 	}
 }
 
-func (mi *MfgImage) rawSectionParts() []mfgPart {
-	parts := make([]mfgPart, len(mi.rawSections))
-	for i, section := range mi.rawSections {
-		parts[i].name = fmt.Sprintf("section-%d (%s)", i, section.filename)
-		parts[i].offset = section.offset
-		parts[i].data = section.data
+func (mi *MfgImage) rawEntryParts() []mfgPart {
+	parts := make([]mfgPart, len(mi.rawEntries))
+	for i, entry := range mi.rawEntries {
+		parts[i].name = fmt.Sprintf("entry-%d (%s)", i, entry.filename)
+		parts[i].offset = entry.offset
+		parts[i].data = entry.data
 	}
 
 	return parts
@@ -387,7 +387,7 @@ func (mi *MfgImage) SrcPaths() []string {
 		paths = append(paths, imageBinPaths(mi.images[1])...)
 	}
 
-	for _, raw := range mi.rawSections {
+	for _, raw := range mi.rawEntries {
 		paths = append(paths, raw.filename)
 	}
 
@@ -405,17 +405,17 @@ func (mi *MfgImage) build() ([][]byte, []byte, error) {
 		return nil, nil, err
 	}
 
-	rawParts := mi.rawSectionParts()
+	rawParts := mi.rawEntryParts()
 
 	parts := append(targetParts, rawParts...)
 	sortParts(parts)
 
-	deviceSections, hash, err := mi.createDeviceSections(parts)
+	sections, hash, err := mi.createSections(parts)
 	if err != nil {
 		return nil, nil, err
 	}
 
-	return deviceSections, hash, nil
+	return sections, hash, nil
 }
 
 func (mi *MfgImage) createManifest(hash []byte) ([]byte, error) {

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/load.go
----------------------------------------------------------------------
diff --git a/newt/mfg/load.go b/newt/mfg/load.go
index 703ba78..0ed9bad 100644
--- a/newt/mfg/load.go
+++ b/newt/mfg/load.go
@@ -77,42 +77,42 @@ func (mi *MfgImage) loadTarget(targetName string) (
 	return tgt, nil
 }
 
-func (mi *MfgImage) loadRawSection(
-	entryIdx int, rawEntry map[string]string) (MfgRawSection, error) {
+func (mi *MfgImage) loadRawEntry(
+	entryIdx int, rawEntry map[string]string) (MfgRawEntry, error) {
 
-	section := MfgRawSection{}
+	raw := MfgRawEntry{}
 
 	offsetStr := rawEntry["offset"]
 	if offsetStr == "" {
-		return section, mi.loadError(
+		return raw, mi.loadError(
 			"raw rawEntry %d missing required \"offset\" field", entryIdx)
 	}
 
 	var err error
-	section.offset, err = util.AtoiNoOct(offsetStr)
+	raw.offset, err = util.AtoiNoOct(offsetStr)
 	if err != nil {
-		return section, mi.loadError(
+		return raw, mi.loadError(
 			"raw rawEntry %d contains invalid offset: %s", entryIdx, offsetStr)
 	}
 
-	section.filename = rawEntry["file"]
-	if section.filename == "" {
-		return section, mi.loadError(
+	raw.filename = rawEntry["file"]
+	if raw.filename == "" {
+		return raw, mi.loadError(
 			"raw rawEntry %d missing required \"file\" field", entryIdx)
 	}
 
-	if !strings.HasPrefix(section.filename, "/") {
-		section.filename = mi.basePkg.BasePath() + "/" + section.filename
+	if !strings.HasPrefix(raw.filename, "/") {
+		raw.filename = mi.basePkg.BasePath() + "/" + raw.filename
 	}
 
-	section.data, err = ioutil.ReadFile(section.filename)
+	raw.data, err = ioutil.ReadFile(raw.filename)
 	if err != nil {
-		return section, mi.loadError(
+		return raw, mi.loadError(
 			"error loading file for raw rawEntry %d; filename=%s: %s",
-			entryIdx, section.filename, err.Error())
+			entryIdx, raw.filename, err.Error())
 	}
 
-	return section, nil
+	return raw, nil
 }
 
 func (mi *MfgImage) areaNameToPart(areaName string) (mfgPart, bool) {
@@ -160,7 +160,7 @@ func (mi *MfgImage) detectOverlaps() error {
 		}
 	}
 
-	parts = append(parts, mi.rawSectionParts()...)
+	parts = append(parts, mi.rawEntryParts()...)
 	sortParts(parts)
 
 	overlaps := []overlap{}
@@ -237,13 +237,13 @@ func Load(basePkg *pkg.LocalPackage) (*MfgImage, error) {
 	slice := cast.ToSlice(itf)
 	if slice != nil {
 		for i, entryItf := range slice {
-			entry := cast.ToStringMapString(entryItf)
-			section, err := mi.loadRawSection(i, entry)
+			yamlEntry := cast.ToStringMapString(entryItf)
+			entry, err := mi.loadRawEntry(i, yamlEntry)
 			if err != nil {
 				return nil, err
 			}
 
-			mi.rawSections = append(mi.rawSections, section)
+			mi.rawEntries = append(mi.rawEntries, entry)
 		}
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/meta.go
----------------------------------------------------------------------
diff --git a/newt/mfg/meta.go b/newt/mfg/meta.go
index d617369..796f08e 100644
--- a/newt/mfg/meta.go
+++ b/newt/mfg/meta.go
@@ -180,10 +180,10 @@ func insertMeta(section0Data []byte, flashMap flash.FlashMap) (int, error) {
 	return metaOff + hashSubOff, nil
 }
 
-func calcMetaHash(deviceSections [][]byte) []byte {
-	// Concatenate all device sections.
+func calcMetaHash(sections [][]byte) []byte {
+	// Concatenate all sections.
 	blob := []byte{}
-	for _, section := range deviceSections {
+	for _, section := range sections {
 		blob = append(blob, section...)
 	}
 

http://git-wip-us.apache.org/repos/asf/incubator-mynewt-newt/blob/53574f43/newt/mfg/mfg.go
----------------------------------------------------------------------
diff --git a/newt/mfg/mfg.go b/newt/mfg/mfg.go
index 6c9d93c..f912c33 100644
--- a/newt/mfg/mfg.go
+++ b/newt/mfg/mfg.go
@@ -45,14 +45,14 @@ type mfgImageSectionHeader struct {
 	Size     uint32 // Does not include header.
 }
 
-type MfgRawSection struct {
+type MfgRawEntry struct {
 	offset   int
 	filename string
 	data     []byte
 }
 
 // A chunk of data in the manufacturing image.  Can be a firmware image or a
-// raw section (contents of a data file).
+// raw entry (contents of a data file).
 type mfgPart struct {
 	offset int
 	data   []byte
@@ -64,9 +64,9 @@ type MfgImage struct {
 
 	bsp *pkg.BspPackage
 
-	boot        *target.Target
-	images      []*target.Target
-	rawSections []MfgRawSection
+	boot       *target.Target
+	images     []*target.Target
+	rawEntries []MfgRawEntry
 }
 
 var MFG_IMAGE_HEADER_SIZE = binary.Size(mfgImageHeader{})