@@ -32,7 +32,7 @@ library ReadCbor {
3232 /// @return arg The parsed argument value
3333 function parseArg (bytes memory cbor , uint i , uint8 minor ) private pure returns (uint n , uint64 arg ) {
3434 if (minor < MinorExtendU8) {
35- return (i, minor);
35+ (n, arg) = (i, minor);
3636 } else if (minor == MinorExtendU8) {
3737 (n, arg) = u8 (cbor, i);
3838 require (arg >= MinorExtendU8, "invalid type argument (single-byte value too low) " );
@@ -87,10 +87,10 @@ library ReadCbor {
8787 /// @return major The major type
8888 function header (bytes memory cbor , uint i ) internal pure returns (uint n , uint64 arg , uint8 major ) {
8989 uint8 h;
90- (i , h) = u8 (cbor, i);
90+ (n , h) = u8 (cbor, i);
9191 major = h >> shiftMajor;
9292 uint8 minor = h & maskMinor;
93- (n, arg) = parseArg (cbor, i , minor);
93+ (n, arg) = parseArg (cbor, n , minor);
9494 }
9595
9696 /// @notice Reads a CBOR header with an expected major type
@@ -102,9 +102,9 @@ library ReadCbor {
102102 /// @dev Reverts if major type doesn't match expected
103103 function header (bytes memory cbor , uint i , uint8 expectMajor ) internal pure returns (uint n , uint64 arg ) {
104104 uint8 h;
105- (i , h) = u8 (cbor, i);
105+ (n , h) = u8 (cbor, i);
106106 require (h >> shiftMajor == expectMajor, "unexpected major type " );
107- (n, arg) = parseArg (cbor, i , h & maskMinor);
107+ (n, arg) = parseArg (cbor, n , h & maskMinor);
108108 }
109109
110110 /// @notice Reads a CBOR header with expected major and minor types
@@ -121,12 +121,12 @@ library ReadCbor {
121121 returns (uint n , uint64 arg )
122122 {
123123 uint8 h;
124- (i , h) = u8 (cbor, i);
124+ (n , h) = u8 (cbor, i);
125125 uint8 major = h >> shiftMajor;
126126 require (major == expectMajor, "unexpected major type " );
127127 uint8 minor = h & maskMinor;
128128 require (minor == expectMinor, "unexpected minor type " );
129- (n, arg) = parseArg (cbor, i , minor);
129+ (n, arg) = parseArg (cbor, n , minor);
130130 }
131131
132132 /// @notice Optimized header reading for uint8 type arguments of an expected major type
@@ -332,15 +332,15 @@ library ReadCbor {
332332 /// @param cbor The CBOR-encoded bytes
333333 /// @param i The current index
334334 /// @return n The new index
335- /// @return ret The string value
336- function String (bytes memory cbor , uint i ) internal pure returns (uint n , string memory ret ) {
335+ /// @return str The string value
336+ function String (bytes memory cbor , uint i ) internal pure returns (uint n , string memory str ) {
337337 uint32 len;
338338 (i, len) = header32 (cbor, i, MajorText);
339339
340- ret = new string (len);
340+ str = new string (len);
341341 assembly ("memory-safe" ) {
342342 let src := add (cbor, add (0x20 , i))
343- let dest := add (ret , 0x20 )
343+ let dest := add (str , 0x20 )
344344 mcopy (dest, src, len)
345345 n := add (i, len)
346346 }
@@ -411,15 +411,15 @@ library ReadCbor {
411411 /// @param cbor The CBOR-encoded bytes
412412 /// @param i The current index
413413 /// @return n The new index
414- /// @return b The byte string value
415- function Bytes (bytes memory cbor , uint i ) internal pure returns (uint n , bytes memory b ) {
414+ /// @return bts The byte string value
415+ function Bytes (bytes memory cbor , uint i ) internal pure returns (uint n , bytes memory bts ) {
416416 uint32 len;
417417 (i, len) = header32 (cbor, i, MajorBytes);
418418
419- b = new bytes (len);
419+ bts = new bytes (len);
420420 assembly ("memory-safe" ) {
421421 let src := add (cbor, add (0x20 , i))
422- let dest := add (b , 0x20 )
422+ let dest := add (bts , 0x20 )
423423 mcopy (dest, src, len)
424424 n := add (i, len)
425425 }
@@ -430,17 +430,17 @@ library ReadCbor {
430430 /// @param i The current index
431431 /// @param maxLen The maximum allowed byte string length, which must be <= 32
432432 /// @return n The new index
433- /// @return b The bytes32 value
433+ /// @return bts The bytes32 value
434434 /// @return len The byte string length
435435 /// @dev Reverts if byte string length exceeds maxLen
436- function Bytes32 (bytes memory cbor , uint i , uint8 maxLen ) internal pure returns (uint n , bytes32 b , uint8 len ) {
436+ function Bytes32 (bytes memory cbor , uint i , uint8 maxLen ) internal pure returns (uint n , bytes32 bts , uint8 len ) {
437437 assert (maxLen <= 32 );
438438 (i, len) = header8 (cbor, i, MajorBytes);
439439 require (len <= maxLen);
440440
441441 assembly ("memory-safe" ) {
442- b := mload (add (cbor, add (0x20 , i)))
443- b := and (b , not (shr (mul (len, 8 ), not (0 ))))
442+ bts := mload (add (cbor, add (0x20 , i)))
443+ bts := and (bts , not (shr (mul (len, 8 ), not (0 ))))
444444 n := add (i, len)
445445 }
446446 }
0 commit comments