From 1391b2d5f332dbfc1e7e7fd2b7ff725caf785994 Mon Sep 17 00:00:00 2001 From: "jim@bo" Date: Thu, 21 Jun 2018 20:05:50 -0400 Subject: PacketRequest deserialize should match serialize --- g | 5 +++-- src/Data/PacketQueue.hs | 5 +++-- src/Network/Tox/Crypto/Transport.hs | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/g b/g index 4b8e922a..e0d5c2b4 100755 --- a/g +++ b/g @@ -2,6 +2,7 @@ rootname=$(cat /etc/debian_chroot 2>/dev/null) echo $PATH | grep '\.stack' >/dev/null && rootname="stack" +BUILDB=build/b warn="-freverse-errors -fwarn-unused-imports -Wmissing-signatures -fdefer-typed-holes" exts="-XOverloadedStrings -XRecordWildCards" @@ -19,7 +20,7 @@ if [ "$rootname" == "stretch" ] then echo "Building with cryptonite backport. (chroot = $rootname)" defs="$defs -DCRYPTONITE_BACKPORT -icryptonite-backport" - warn="build/b/cbits/cryptonite_salsa.o build/b/cbits/cryptonite_xsalsa.o $warn" + warn="$BUILDB/cbits/cryptonite_salsa.o $BUILDB/cbits/cryptonite_xsalsa.o $warn" fi root=${0%/*} @@ -35,6 +36,6 @@ ghc -threaded \ -iPresence \ -iArchive \ -isrc \ - build/b/Presence/monitortty.o \ + $BUILDB/Presence/monitortty.o \ $warn \ "$@" diff --git a/src/Data/PacketQueue.hs b/src/Data/PacketQueue.hs index 8182706e..b5d8a756 100644 --- a/src/Data/PacketQueue.hs +++ b/src/Data/PacketQueue.hs @@ -220,11 +220,12 @@ getRequested getExtra pktoq snum ns = do toIndex = (`mod` qsize (pktoOutPQ pktoq)) toPNums :: Word32 -> [Word8] -> [Word32] - toPNums snum ns = reverse . snd $ foldl doOne ((snum - 1),[]) ns + toPNums snum ns = reverse . snd $ foldl doOne (snum,[]) ns where doOne :: (Word32,[Word32]) -> Word8 -> (Word32,[Word32]) doOne (addend,as) 0 = (addend+255,as) - doOne (addend,as) x = (addend,(fromIntegral x + addend):as) + doOne (addend,as) x = let y = fromIntegral x + addend + in (y,y:as) peekPacket :: STM extra -> PacketOutQueue extra msg wire fromwire -> msg -> STM (Maybe (wire,Word32)) peekPacket getExtra q@(PacketOutQueue { pktoInPQ, pktoOutPQ, pktoPacketNo, pktoToWireIO, pktoToWire }) msg diff --git a/src/Network/Tox/Crypto/Transport.hs b/src/Network/Tox/Crypto/Transport.hs index 67950854..678bb16d 100644 --- a/src/Network/Tox/Crypto/Transport.hs +++ b/src/Network/Tox/Crypto/Transport.hs @@ -185,7 +185,7 @@ data CryptoData = CryptoData , bufferEnd :: Word32 -- | [data] (TODO See Note [Padding]) , bufferData :: CryptoMessage - } + } deriving (Eq,Show) {- Note [Padding] -- cgit v1.2.3