Revision 438e6c03

View differences:

include/chunkidset.h
16 16
*/
17 17
typedef struct chunkID_set ChunkIDSet;
18 18

  
19
#define CHUNKID_INVALID ((2^32) - 1)
20

  
19 21
 /**
20 22
  * @brief Allocate a chunk ID set.
21 23
  * 
......
109 111
  */
110 112
void chunkID_set_free(struct chunkID_set *h);
111 113

  
112
int chunkID_set_get_earliest(const struct chunkID_set *h);
114
uint32_t chunkID_set_get_earliest(const struct chunkID_set *h);
113 115

  
114
int chunkID_set_get_latest(const struct chunkID_set *h);
116
uint32_t chunkID_set_get_latest(const struct chunkID_set *h);
115 117

  
116 118
#endif	/* CHUNKIDSET_H */
som/ChunkIDSet/chunkids_ha.c
6 6

  
7 7
#include <stdlib.h>
8 8
#include <stdint.h>
9
#include <limits.h>
10 9
#include <assert.h>
11 10

  
12 11
#include "chunkidset.h"
13 12

  
14
int chunkID_set_get_earliest(const struct chunkID_set *h)
13
uint32_t chunkID_set_get_earliest(const struct chunkID_set *h)
15 14
{
16
  int i, min;
15
  int i;
16
  uint32_t min;
17 17

  
18 18
  if (chunkID_set_size(h) == 0) {
19
    return -1;
19
    return CHUNKID_INVALID;
20 20
  }
21 21
  min = chunkID_set_get_chunk(h, 0);
22 22
  for (i = 1; i < chunkID_set_size(h); i++) {
......
28 28
  return min;
29 29
}
30 30

  
31
int chunkID_set_get_latest(const struct chunkID_set *h)
31
uint32_t chunkID_set_get_latest(const struct chunkID_set *h)
32 32
{
33
  int i, max;
33
  int i;
34
  uint32_t  max;
34 35

  
35 36
  if (chunkID_set_size(h) == 0) {
36
    return -1;
37
    return CHUNKID_INVALID;
37 38
  }
38 39
  max = chunkID_set_get_chunk(h, 0);
39 40
  for (i = 1; i < chunkID_set_size(h); i++) {
som/Tests/chunkidset_test_bug.c
4 4
 *  This is free software; see gpl-3.0.txt
5 5
 */
6 6

  
7
#include <inttypes.h>
7 8
#include <stdint.h>
8 9
#include <stdlib.h>
9 10
#include <stdio.h>
10 11
#include <string.h>
12

  
11 13
#include "chunkidset.h"
12
#include "trade_sig_la.h"
14

  
13 15
#include "chunkid_set_h.h"
14 16

  
15 17
static void display_cset(struct chunkID_set *cset)
16 18
{
17 19
  printf("Chunk ID Set initialised: size is %d\n", chunkID_set_size(cset));
18 20
  printChunkID_set(cset);
19
  printf("Earliest chunk %d\n", chunkID_set_get_earliest(cset));
21
  printf("Earliest chunk %"PRIu32"\n", chunkID_set_get_earliest(cset));
20 22
  check_chunk(cset, 0);
21
  printf("Latest chunk %d.\n", chunkID_set_get_latest(cset));
23
  printf("Latest chunk %"PRIu32"\n", chunkID_set_get_latest(cset));
22 24
  check_chunk(cset, 0);
23 25
}
24 26

  

Also available in: Unified diff