Skip to content

Commit

Permalink
On Visual Studio, Enable Warning 4244: 'conversion' conversion from '…
Browse files Browse the repository at this point in the history
…type1'

to 'type2', possible lose of data.
  • Loading branch information
ggcueroad committed Feb 18, 2012
1 parent 276ca2c commit 7d2cbbc
Show file tree
Hide file tree
Showing 40 changed files with 329 additions and 293 deletions.
8 changes: 4 additions & 4 deletions libarchive/archive_endian.h
Expand Up @@ -126,8 +126,8 @@ archive_be64enc(void *pp, uint64_t u)
{ {
unsigned char *p = (unsigned char *)pp; unsigned char *p = (unsigned char *)pp;


archive_be32enc(p, u >> 32); archive_be32enc(p, (uint32_t)(u >> 32));
archive_be32enc(p + 4, u & 0xffffffff); archive_be32enc(p + 4, (uint32_t)(u & 0xffffffff));
} }


static inline void static inline void
Expand Down Expand Up @@ -155,8 +155,8 @@ archive_le64enc(void *pp, uint64_t u)
{ {
unsigned char *p = (unsigned char *)pp; unsigned char *p = (unsigned char *)pp;


archive_le32enc(p, u & 0xffffffff); archive_le32enc(p, (uint32_t)(u & 0xffffffff));
archive_le32enc(p + 4, u >> 32); archive_le32enc(p + 4, (uint32_t)(u >> 32));
} }


#endif #endif
2 changes: 1 addition & 1 deletion libarchive/archive_entry_link_resolver.c
Expand Up @@ -362,7 +362,7 @@ insert_entry(struct archive_entry_linkresolver *res,
if (res->number_entries > res->number_buckets * 2) if (res->number_entries > res->number_buckets * 2)
grow_hash(res); grow_hash(res);


hash = archive_entry_dev(entry) ^ archive_entry_ino64(entry); hash = (size_t)(archive_entry_dev(entry) ^ archive_entry_ino64(entry));
bucket = hash & (res->number_buckets - 1); bucket = hash & (res->number_buckets - 1);


/* If we could allocate the entry, record it. */ /* If we could allocate the entry, record it. */
Expand Down
8 changes: 4 additions & 4 deletions libarchive/archive_entry_stat.c
Expand Up @@ -70,12 +70,12 @@ archive_entry_stat(struct archive_entry *entry)
st->st_ctime = archive_entry_ctime(entry); st->st_ctime = archive_entry_ctime(entry);
st->st_mtime = archive_entry_mtime(entry); st->st_mtime = archive_entry_mtime(entry);
st->st_dev = archive_entry_dev(entry); st->st_dev = archive_entry_dev(entry);
st->st_gid = archive_entry_gid(entry); st->st_gid = (gid_t)archive_entry_gid(entry);
st->st_uid = archive_entry_uid(entry); st->st_uid = (uid_t)archive_entry_uid(entry);
st->st_ino = archive_entry_ino64(entry); st->st_ino = (ino_t)archive_entry_ino64(entry);
st->st_nlink = archive_entry_nlink(entry); st->st_nlink = archive_entry_nlink(entry);
st->st_rdev = archive_entry_rdev(entry); st->st_rdev = archive_entry_rdev(entry);
st->st_size = archive_entry_size(entry); st->st_size = (off_t)archive_entry_size(entry);
st->st_mode = archive_entry_mode(entry); st->st_mode = archive_entry_mode(entry);


/* /*
Expand Down
10 changes: 5 additions & 5 deletions libarchive/archive_read.c
Expand Up @@ -638,8 +638,8 @@ archive_read_data(struct archive *_a, void *buff, size_t s)
len = s; len = s;
} else if (a->read_data_output_offset < } else if (a->read_data_output_offset <
a->read_data_offset) { a->read_data_offset) {
len = a->read_data_offset - len = (size_t)(a->read_data_offset -
a->read_data_output_offset; a->read_data_output_offset);
} else } else
len = 0; len = 0;


Expand Down Expand Up @@ -1231,7 +1231,7 @@ advance_file_pointer(struct archive_read_filter *filter, int64_t request)


/* Use up the copy buffer first. */ /* Use up the copy buffer first. */
if (filter->avail > 0) { if (filter->avail > 0) {
min = minimum(request, (int64_t)filter->avail); min = (size_t)minimum(request, (int64_t)filter->avail);
filter->next += min; filter->next += min;
filter->avail -= min; filter->avail -= min;
request -= min; request -= min;
Expand All @@ -1241,7 +1241,7 @@ advance_file_pointer(struct archive_read_filter *filter, int64_t request)


/* Then use up the client buffer. */ /* Then use up the client buffer. */
if (filter->client_avail > 0) { if (filter->client_avail > 0) {
min = minimum(request, (int64_t)filter->client_avail); min = (size_t)minimum(request, (int64_t)filter->client_avail);
filter->client_next += min; filter->client_next += min;
filter->client_avail -= min; filter->client_avail -= min;
request -= min; request -= min;
Expand Down Expand Up @@ -1283,7 +1283,7 @@ advance_file_pointer(struct archive_read_filter *filter, int64_t request)
if (bytes_read >= request) { if (bytes_read >= request) {
filter->client_next = filter->client_next =
((const char *)filter->client_buff) + request; ((const char *)filter->client_buff) + request;
filter->client_avail = bytes_read - request; filter->client_avail = (size_t)(bytes_read - request);
filter->client_total = bytes_read; filter->client_total = bytes_read;
total_bytes_skipped += request; total_bytes_skipped += request;
filter->position += request; filter->position += request;
Expand Down
6 changes: 3 additions & 3 deletions libarchive/archive_read_disk_windows.c
Expand Up @@ -552,7 +552,7 @@ trivial_lookup_uname(void *private_data, int64_t uid)
static int64_t static int64_t
align_num_per_sector(struct tree *t, int64_t size) align_num_per_sector(struct tree *t, int64_t size)
{ {
int surplus; int64_t surplus;


size += t->current_filesystem->bytesPerSector -1; size += t->current_filesystem->bytesPerSector -1;
surplus = size % t->current_filesystem->bytesPerSector; surplus = size % t->current_filesystem->bytesPerSector;
Expand Down Expand Up @@ -599,7 +599,7 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)


buffbytes = olp->buff_size; buffbytes = olp->buff_size;
if (buffbytes > t->current_sparse->length) if (buffbytes > t->current_sparse->length)
buffbytes = t->current_sparse->length; buffbytes = (DWORD)t->current_sparse->length;


/* Skip hole. */ /* Skip hole. */
if (t->current_sparse->offset > t->ol_total) { if (t->current_sparse->offset > t->ol_total) {
Expand All @@ -615,7 +615,7 @@ start_next_async_read(struct archive_read_disk *a, struct tree *t)
olp->bytes_expected = buffbytes; olp->bytes_expected = buffbytes;
t->ol_remaining_bytes -= buffbytes; t->ol_remaining_bytes -= buffbytes;
} else { } else {
olp->bytes_expected = t->ol_remaining_bytes; olp->bytes_expected = (size_t)t->ol_remaining_bytes;
t->ol_remaining_bytes = 0; t->ol_remaining_bytes = 0;
} }
olp->bytes_transferred = 0; olp->bytes_transferred = 0;
Expand Down
4 changes: 2 additions & 2 deletions libarchive/archive_read_open_fd.c
Expand Up @@ -129,8 +129,8 @@ static int64_t
file_skip(struct archive *a, void *client_data, int64_t request) file_skip(struct archive *a, void *client_data, int64_t request)
{ {
struct read_fd_data *mine = (struct read_fd_data *)client_data; struct read_fd_data *mine = (struct read_fd_data *)client_data;
off_t skip = (off_t)request; int64_t skip = request;
off_t old_offset, new_offset; int64_t old_offset, new_offset;
int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */ int skip_bits = sizeof(skip) * 8 - 1; /* off_t is a signed type. */


if (!mine->use_lseek) if (!mine->use_lseek)
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_open_filename.c
Expand Up @@ -454,7 +454,7 @@ static int64_t
file_seek(struct archive *a, void *client_data, int64_t request, int whence) file_seek(struct archive *a, void *client_data, int64_t request, int whence)
{ {
struct read_file_data *mine = (struct read_file_data *)client_data; struct read_file_data *mine = (struct read_file_data *)client_data;
off_t r; int64_t r;


/* We use off_t here because lseek() is declared that way. */ /* We use off_t here because lseek() is declared that way. */
/* See above for notes about when off_t is less than 64 bits. */ /* See above for notes about when off_t is less than 64 bits. */
Expand Down
4 changes: 2 additions & 2 deletions libarchive/archive_read_private.h
Expand Up @@ -134,8 +134,8 @@ struct archive_read {


/* Dev/ino of the archive being read/written. */ /* Dev/ino of the archive being read/written. */
int skip_file_set; int skip_file_set;
dev_t skip_file_dev; int64_t skip_file_dev;
ino_t skip_file_ino; int64_t skip_file_ino;


/* /*
* Used by archive_read_data() to track blocks and copy * Used by archive_read_data() to track blocks and copy
Expand Down
2 changes: 1 addition & 1 deletion libarchive/archive_read_support_filter_rpm.c
Expand Up @@ -188,7 +188,7 @@ rpm_filter_read(struct archive_read_filter *self, const void **buff)
if (rpm->total_in + avail_in < RPM_LEAD_SIZE) if (rpm->total_in + avail_in < RPM_LEAD_SIZE)
used += avail_in; used += avail_in;
else { else {
n = RPM_LEAD_SIZE - rpm->total_in; n = (size_t)(RPM_LEAD_SIZE - rpm->total_in);
used += n; used += n;
b += n; b += n;
rpm->state = ST_HEADER; rpm->state = ST_HEADER;
Expand Down

0 comments on commit 7d2cbbc

Please sign in to comment.