Skip to content

Commit

Permalink
fix MSVC warnings, version bump
Browse files Browse the repository at this point in the history
  • Loading branch information
jcupitt committed Oct 3, 2023
1 parent cd39812 commit a8a1f2a
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 23 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
## master

- fix MSVC compiler warnings [jcupitt]
- only use `__attribute__((constructor))` if supported [bgilbert]

## 1.0.0, 2/9/23

- first release!

4 changes: 2 additions & 2 deletions meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ project(
],
license : 'MIT',
meson_version : '>=0.50',
version : '1.0.0'
version : '1.0.1'
)
if not meson.is_subproject()
meson.add_dist_script(
Expand All @@ -35,7 +35,7 @@ endif
# 3. Other, eg. bugfix: bump patch
abi_version_major = 1
abi_version_minor = 0
abi_version_patch = 0
abi_version_patch = 1

abi_version = '@0@.@1@.@2@'.format(
abi_version_major,
Expand Down
20 changes: 10 additions & 10 deletions src/dicom-data.c
Original file line number Diff line number Diff line change
Expand Up @@ -478,7 +478,7 @@ bool dcm_element_set_value_string_multi(DcmError **error,

element->vm = vm;

size_t length = 0;
uint32_t length = 0;
for (uint32_t i = 0; i < vm; i++) {
length += strlen(values[i]);
}
Expand Down Expand Up @@ -576,7 +576,7 @@ bool dcm_element_set_value_string(DcmError **error,
}

element->vm = 1;
element_set_length(element, strlen(value));
element_set_length(element, (uint32_t) strlen(value));

if (!dcm_element_validate(error, element)) {
return false;
Expand All @@ -598,7 +598,7 @@ static int64_t value_to_int64(DcmVR vr, int *value)
{
uint64_t result = 0;

#define PEEK(TYPE) result = *((TYPE *) value)
#define PEEK(TYPE) result = (uint64_t) *((TYPE *) value)
DCM_SWITCH_NUMERIC(vr, PEEK);
#undef PEEK

Expand All @@ -610,7 +610,7 @@ static int64_t value_to_int64(DcmVR vr, int *value)
static void int64_to_value(DcmVR vr, int *result, int64_t value)
{
*result = 0;
#define POKE(TYPE) *((TYPE *) result) = value;
#define POKE(TYPE) *((TYPE *) result) = (TYPE) value;
DCM_SWITCH_NUMERIC(vr, POKE);
#undef POKE
}
Expand Down Expand Up @@ -697,7 +697,7 @@ bool dcm_element_set_value_integer(DcmError **error,
int *element_value = (int *) &element->value.single.sl;
int64_to_value(element->vr, element_value, value);
element->vm = 1;
element_set_length(element, dcm_dict_vr_size(element->vr));
element_set_length(element, (uint32_t) dcm_dict_vr_size(element->vr));

if (!dcm_element_validate(error, element)) {
return false;
Expand Down Expand Up @@ -741,7 +741,7 @@ bool dcm_element_set_value_numeric_multi(DcmError **error,
}

element->vm = vm;
element_set_length(element, size_in_bytes);
element_set_length(element, (uint32_t) size_in_bytes);

if (!dcm_element_validate(error, element)) {
return false;
Expand All @@ -762,7 +762,7 @@ static double value_to_double(DcmVR vr, double *value)
{
double result = 0.0;

#define PEEK(TYPE) result = *((TYPE *) value)
#define PEEK(TYPE) result = (double) *((TYPE *) value)
DCM_SWITCH_NUMERIC(vr, PEEK);
#undef PEEK

Expand All @@ -774,7 +774,7 @@ static double value_to_double(DcmVR vr, double *value)
static void double_to_value(DcmVR vr, double *result, double value)
{
*result = 0.0;
#define POKE(TYPE) *((TYPE *) result) = value;
#define POKE(TYPE) *((TYPE *) result) = (TYPE) value;
DCM_SWITCH_NUMERIC(vr, POKE);
#undef POKE
}
Expand Down Expand Up @@ -834,7 +834,7 @@ bool dcm_element_set_value_decimal(DcmError **error,
double *element_value = (double *) &element->value.single.fd;
double_to_value(element->vr, element_value, value);
element->vm = 1;
element_set_length(element, dcm_dict_vr_size(element->vr));
element_set_length(element, (uint32_t) dcm_dict_vr_size(element->vr));

if (!dcm_element_validate(error, element)) {
return false;
Expand Down Expand Up @@ -1284,7 +1284,7 @@ char *dcm_element_value_to_string(const DcmElement *element)
(void) dcm_element_get_value_integer(NULL, element, 0, &grp);
(void) dcm_element_get_value_integer(NULL, element, 1, &ele);

uint32_t tag = grp << 16 | ele;
uint32_t tag = (uint32_t) grp << 16 | (uint32_t) ele;

const char *keyword = dcm_dict_keyword_from_tag(tag);

Expand Down
23 changes: 12 additions & 11 deletions src/dicom-io.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ typedef struct _DcmIOFile {
int fd;
char *filename;
char input_buffer[BUFFER_SIZE];
int bytes_in_buffer;
int read_point;
int64_t bytes_in_buffer;
int64_t read_point;
} DcmIOFile;


Expand Down Expand Up @@ -120,7 +120,8 @@ static int64_t read_file(DcmError **error, DcmIOFile *file,
int64_t bytes_read;

#ifdef _WIN32
bytes_read = _read(file->fd, buffer, length);
// we'll never read a huge chunk (hopefully)
bytes_read = _read(file->fd, buffer, (uint32_t) length);
#else
do {
bytes_read = read(file->fd, buffer, length);
Expand Down Expand Up @@ -179,8 +180,8 @@ static int64_t dcm_io_read_file(DcmError **error, DcmIO *io,

/* Read what we can from the buffer.
*/
int bytes_available = file->bytes_in_buffer - file->read_point;
int bytes_to_copy = MIN(bytes_available, length);
int64_t bytes_available = file->bytes_in_buffer - file->read_point;
int64_t bytes_to_copy = MIN(bytes_available, length);

memcpy(buffer,
file->input_buffer + file->read_point,
Expand Down Expand Up @@ -309,8 +310,8 @@ static int64_t dcm_io_read_memory(DcmError **error, DcmIO *io,

USED(error);

int bytes_available = memory->length - memory->read_point;
int bytes_to_copy = MIN(bytes_available, length);
int64_t bytes_available = memory->length - memory->read_point;
int64_t bytes_to_copy = MIN(bytes_available, length);
memcpy(buffer,
memory->buffer + memory->read_point,
bytes_to_copy);
Expand Down Expand Up @@ -355,7 +356,7 @@ static int64_t dcm_io_seek_memory(DcmError **error, DcmIO *io,


DcmIO *dcm_io_create_from_memory(DcmError **error,
const char *buffer,
const char *buffer,
int64_t length)
{
static DcmIOMethods methods = {
Expand Down Expand Up @@ -391,9 +392,9 @@ int64_t dcm_io_read(DcmError **error,
}


int64_t dcm_io_seek(DcmError **error,
DcmIO *io,
int64_t offset,
int64_t dcm_io_seek(DcmError **error,
DcmIO *io,
int64_t offset,
int whence)
{
return io->methods->seek(error, io, offset, whence);
Expand Down

0 comments on commit a8a1f2a

Please sign in to comment.