You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by GitBox <gi...@apache.org> on 2018/07/12 17:13:43 UTC

[GitHub] ccollins476ad closed pull request #95: Fix [un]marshal of log-entry-type

ccollins476ad closed pull request #95: Fix [un]marshal of log-entry-type
URL: https://github.com/apache/mynewt-newtmgr/pull/95
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/nmxact/nmp/log.go b/nmxact/nmp/log.go
index 33a35ce9..39952066 100644
--- a/nmxact/nmp/log.go
+++ b/nmxact/nmp/log.go
@@ -21,8 +21,6 @@ package nmp
 
 import (
 	"fmt"
-
-	"github.com/ugorji/go/codec"
 )
 
 //////////////////////////////////////////////////////////////////////////////
@@ -125,7 +123,7 @@ var LogEntryTypeStringMap = map[LogEntryType]string{
 }
 
 type LogShowReq struct {
-	NmpBase          `codec:"-"`
+	NmpBase   `codec:"-"`
 	Name      string `codec:"log_name"`
 	Timestamp int64  `codec:"ts"`
 	Index     uint32 `codec:"index"`
@@ -305,37 +303,17 @@ func (l LogEntryType) String() string {
 	return LogEntryTypeToString(l)
 }
 
-func (l LogEntryType) MarshalBinary([]byte, error) error {
-	var err error
-	var s string
-	var b []byte
-
-	handle := new(codec.CborHandle)
-
-	s = LogEntryTypeToString(l)
-
-	dec := codec.NewEncoderBytes(&b, handle)
-
-	err = dec.Encode(&b)
-	if err != nil {
-		return err
-	}
-
-	b = append(b, s...)
-
-	return err
+func (l LogEntryType) MarshalBinary() ([]byte, error) {
+	return []byte(l.String()), nil
 }
 
 func (l *LogEntryType) UnmarshalBinary(data []byte) error {
 	var err error
-	var s string
-
-	handle := new(codec.CborHandle)
-	dec := codec.NewDecoderBytes(data, handle)
 
-	err = dec.Decode(&s)
-
-	*l, err = LogEntryTypeFromString(s)
+	*l, err = LogEntryTypeFromString(string(data))
+	if err != nil {
+		return err
+	}
 
-	return err
+	return nil
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services