[ https://issues.apache.org/jira/browse/QPID-6470?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14394093#comment-14394093 ]
Alan Conway commented on QPID-6470: ----------------------------------- Yes. ConvertIfRrequired(p, n) swaps the bytes p..p+n in place and returns pointer p. The current code swaps the encoded octets, then copies that to the return value. That works the first time, but the second time in octets are backwards so you get a bogus result. It alternates between giving the right answer and the swapped answer. What the patch does is copy the octets to the return value, then swap the return value so the octets are unchanged. I have this fix, I added some unit tests and discovered some more issues (incorrect conversions from float to int and some missing get/set functions) The type info is somewhat in the wrong place. A FixedWidthValue only knows its width, not its type, so it can't implement convertibleToInt() correctly (the current implementation returns true, which is wrong if the value contains a float and results in an invalid byte-copy conversion giving a nonsense value.) I'm trying to decide the least disturbing way to get the type info to the convertibleTo tests, or maybe introduce subclasses for FixedWidthFloatValue and FixedWidthIntValue. > FieldValue::getFloatingPointValue() converts endian each time it is called > -------------------------------------------------------------------------- > > Key: QPID-6470 > URL: https://issues.apache.org/jira/browse/QPID-6470 > Project: Qpid > Issue Type: Bug > Components: C++ Broker, C++ Client, C++ Clustering > Affects Versions: 0.32, 0.33 > Environment: Windows 7 > Reporter: Pavel Pokutnev > Assignee: Alan Conway > Priority: Critical > Labels: easyfix, patch > Original Estimate: 0.5h > Remaining Estimate: 0.5h > > When calling getFloatingPointValue multiple times, the octets are > endian-converted each time. > Actually we need to make a copy first and then call convertIfRequired(). -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@qpid.apache.org For additional commands, e-mail: dev-h...@qpid.apache.org