diff --git a/lib/c/2014/labcomm2014.h b/lib/c/2014/labcomm2014.h index 5931e83ec07edc033735569355529176120bb032..ca490ccb6a0b375fd0cdcfac3b6c6215a24b5488 100644 --- a/lib/c/2014/labcomm2014.h +++ b/lib/c/2014/labcomm2014.h @@ -30,11 +30,15 @@ #else #include <stdint.h> #include <unistd.h> + #include <limits.h> #endif #include "labcomm2014_error.h" #include "labcomm2014_scheduler.h" +/* Bits set in result of labcomm_decode_one */ +#define LABCOMM2014_IS_SAMPLE (INT_MAX - (INT_MAX>>1)) + /* Forward declaration */ struct labcomm2014_encoder; struct labcomm2014_decoder; diff --git a/lib/c/2014/labcomm2014_decoder.c b/lib/c/2014/labcomm2014_decoder.c index b38de4051862e8e4c5b4eed5e415ff2732d20acc..e270afc4a464d1f3b4752d639165ddd75192bdc6 100644 --- a/lib/c/2014/labcomm2014_decoder.c +++ b/lib/c/2014/labcomm2014_decoder.c @@ -387,7 +387,7 @@ static int do_decode_one(struct labcomm2014_decoder *d) DECODER_DEBUG_FPRINTF(stderr, "SKIP %d %d\n", remote_index, length); result = decoder_skip(d, length, remote_index); } else { - result = decode_and_handle(d, d, remote_index); + result = decode_and_handle(d, d, remote_index) | LABCOMM2014_IS_SAMPLE; } out: return result; diff --git a/lib/c/2014/test/test_labcomm.c b/lib/c/2014/test/test_labcomm.c index 81cc07b68ed6fa4058fbf40694b486cb375fc458..9f093f295c5f4513cee7019b0e0651af8998bc81 100644 --- a/lib/c/2014/test/test_labcomm.c +++ b/lib/c/2014/test/test_labcomm.c @@ -229,6 +229,11 @@ static void test_encode_decode(struct labcomm2014_encoder *encoder, writer.pos, expected); exit(1); } + if ((err & LABCOMM2014_IS_SAMPLE) == 0) { + fprintf(stderr, "Expected %x set in %x\n", + LABCOMM2014_IS_SAMPLE, err); + exit(1); + } } static int do_test(int argc, char *argv[])