Skip to content

Commit d3ea7f7

Browse files
committed
all: fix implicit integer conversions.
git-svn-id: https://svn.macosforge.org/repository/darwinbuild/trunk@1057 10a61168-4876-4dac-953b-31e694342555
1 parent 5b2b80b commit d3ea7f7

File tree

23 files changed

+79
-73
lines changed

23 files changed

+79
-73
lines changed

CHANGES

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
Darwin Build Scripts Change History
22
-----------------------------------
3+
Release 35 [24-Apr-2013]
4+
- all: fix implicit integer conversions.
5+
36
Release 34.1 [14-Mar-2013]
47
Release 34 [12-Mar-2013]
58
- darwintrace: avoid snprintf(3); manually construct log messages.

darwinbuild.xcodeproj/project.pbxproj

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3404,6 +3404,7 @@
34043404
GCC_MODEL_TUNING = "";
34053405
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
34063406
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
3407+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
34073408
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
34083409
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
34093410
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3550,6 +3551,7 @@
35503551
GCC_MODEL_TUNING = "";
35513552
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
35523553
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
3554+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
35533555
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
35543556
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
35553557
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3585,6 +3587,7 @@
35853587
GCC_MODEL_TUNING = "";
35863588
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
35873589
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
3590+
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
35883591
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
35893592
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
35903593
GCC_WARN_ABOUT_RETURN_TYPE = YES;

darwinbuild/digest.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ char* calculate_digest(int fd) {
8484
if (len == 0) { close(fd); break; }
8585
if ((len < 0) && (errno == EINTR)) continue;
8686
if (len < 0) { close(fd); return NULL; }
87-
CC_SHA1_Update(&c, block, (size_t)len);
87+
CC_SHA1_Update(&c, block, (CC_LONG)len);
8888
}
8989

9090
CC_SHA1_Final(md, &c);

darwinbuild/manifest.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ static char* calculate_digest(int fd) {
8080
if (len == 0) { close(fd); break; }
8181
if ((len < 0) && (errno == EINTR)) continue;
8282
if (len < 0) { close(fd); return NULL; }
83-
CC_SHA1_Update(&c, block, (size_t)len);
83+
CC_SHA1_Update(&c, block, (CC_LONG)len);
8484
}
8585

8686
CC_SHA1_Final(md, &c);
@@ -103,7 +103,7 @@ static void ent_filename(FTSENT* ent, char* filename) {
103103
}
104104
#endif
105105

106-
static int ent_filename(FTSENT* ent, char* filename, size_t bufsiz) {
106+
static size_t ent_filename(FTSENT* ent, char* filename, size_t bufsiz) {
107107
if (ent == NULL) return 0;
108108
if (ent->fts_level > 1) {
109109
bufsiz = ent_filename(ent->fts_parent, filename, bufsiz);
@@ -130,7 +130,7 @@ int main(int argc, char* argv[]) {
130130
while ((ent = fts_read(fts)) != NULL) {
131131
char filename[MAXPATHLEN+1];
132132
char symlink[MAXPATHLEN+1];
133-
int len;
133+
ssize_t len;
134134

135135
// Filename
136136
filename[0] = 0;

darwinup/DB.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ int DarwinupDatabase::set_archive_active(uint64_t serial, uint64_t* active) {
105105
}
106106

107107
int DarwinupDatabase::update_archive(uint64_t serial, uuid_t uuid, const char* name,
108-
time_t date_added, uint32_t active, uint32_t info,
108+
time_t date_added, uint32_t active, uint64_t info,
109109
const char* build) {
110110
this->clear_last_archive();
111111
return this->update(this->m_archives_table, serial,
@@ -118,7 +118,7 @@ int DarwinupDatabase::update_archive(uint64_t serial, uuid_t uuid, const char* n
118118
build);
119119
}
120120

121-
uint64_t DarwinupDatabase::insert_archive(uuid_t uuid, uint32_t info, const char* name,
121+
uint64_t DarwinupDatabase::insert_archive(uuid_t uuid, uint64_t info, const char* name,
122122
time_t date_added, const char* build) {
123123

124124
int res = this->insert(this->m_archives_table,
@@ -184,7 +184,7 @@ File* DarwinupDatabase::make_file(uint8_t* data) {
184184
return NULL;
185185
}
186186

187-
File* result = FileFactory(serial, archive, info, (const char*)path, mode, uid, gid, size, digest);
187+
File* result = FileFactory(serial, archive, (uint32_t)info, (const char*)path, mode, (uid_t)uid, (gid_t)gid, size, digest);
188188
this->m_files_table->free_result(data);
189189

190190
return result;
@@ -235,7 +235,7 @@ int DarwinupDatabase::get_file_serial_from_archive(Archive* archive, const char*
235235
return DB_ERROR;
236236
}
237237

238-
int DarwinupDatabase::update_file(uint64_t serial, Archive* archive, uint32_t info, mode_t mode,
238+
int DarwinupDatabase::update_file(uint64_t serial, Archive* archive, uint64_t info, mode_t mode,
239239
uid_t uid, gid_t gid, Digest* digest, const char* path) {
240240

241241
int res = SQLITE_OK;
@@ -260,7 +260,7 @@ int DarwinupDatabase::update_file(uint64_t serial, Archive* archive, uint32_t in
260260
return res;
261261
}
262262

263-
uint64_t DarwinupDatabase::insert_file(uint32_t info, mode_t mode, uid_t uid, gid_t gid,
263+
uint64_t DarwinupDatabase::insert_file(uint64_t info, mode_t mode, uid_t uid, gid_t gid,
264264
Digest* digest, Archive* archive, const char* path) {
265265

266266
int res = this->insert(this->m_files_table,

darwinup/DB.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,9 @@ struct DarwinupDatabase : Database {
7373
int activate_archive(uint64_t serial);
7474
int deactivate_archive(uint64_t serial);
7575
int update_archive(uint64_t serial, uuid_t uuid, const char* name,
76-
time_t date_added, uint32_t active, uint32_t info,
76+
time_t date_added, uint32_t active, uint64_t info,
7777
const char* build);
78-
uint64_t insert_archive(uuid_t uuid, uint32_t info, const char* name,
78+
uint64_t insert_archive(uuid_t uuid, uint64_t info, const char* name,
7979
time_t date, const char* build);
8080
int delete_empty_archives();
8181
int delete_archive(Archive* archive);
@@ -90,9 +90,9 @@ struct DarwinupDatabase : Database {
9090
uint64_t** serial);
9191
int get_files(uint8_t*** data, uint32_t* count, Archive* archive, bool reverse);
9292
int file_offset(int column);
93-
int update_file(uint64_t serial, Archive* archive, uint32_t info, mode_t mode,
93+
int update_file(uint64_t serial, Archive* archive, uint64_t info, mode_t mode,
9494
uid_t uid, gid_t gid, Digest* digest, const char* path);
95-
uint64_t insert_file(uint32_t info, mode_t mode, uid_t uid, gid_t gid,
95+
uint64_t insert_file(uint64_t info, mode_t mode, uid_t uid, gid_t gid,
9696
Digest* digest, Archive* archive, const char* path);
9797
int delete_file(uint64_t serial);
9898
int delete_file(File* file);

darwinup/Database.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -606,7 +606,7 @@ int Database::sql(const char* name, const char* fmt, ...) {
606606
va_list args;
607607
va_start(args, fmt);
608608
char* query = sqlite3_vmprintf(fmt, args);
609-
int res = sqlite3_prepare_v2(m_db, query, strlen(query), &stmt, NULL);
609+
int res = sqlite3_prepare_v2(m_db, query, (int)strlen(query), &stmt, NULL);
610610
va_end(args);
611611
if (res != SQLITE_OK) {
612612
fprintf(stderr, "Error: unable to prepare statement for query: %s\n"
@@ -890,7 +890,7 @@ int Database::step_once(sqlite3_stmt* stmt, uint8_t* output, uint32_t* used) {
890890
current += this->store_column(stmt, i, current);
891891
}
892892
if (used) {
893-
*used = current - output;
893+
*used = (uint32_t)(current - output);
894894
}
895895
}
896896

darwinup/Depot.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1001,7 +1001,7 @@ int Depot::uninstall_file(File* file, void* ctx) {
10011001
context->depot->m_modified_extensions = true;
10021002
}
10031003
}
1004-
uint32_t info = preceding->info();
1004+
uint64_t info = preceding->info();
10051005
if (INFO_TEST(info, FILE_INFO_NO_ENTRY | FILE_INFO_ROLLBACK_DATA) &&
10061006
!INFO_TEST(info, FILE_INFO_BASE_SYSTEM)) {
10071007
if (!dryrun && res == 0) {
@@ -1198,13 +1198,13 @@ int Depot::list(int count, char** args) {
11981198
if (archive) res = this->list_archive(archive, stdout);
11991199
}
12001200
}
1201-
1201+
12021202
return res;
12031203
}
12041204

12051205
int Depot::print_file(File* file, void* context) {
12061206
extern uint32_t verbosity;
1207-
if (verbosity & VERBOSE_DEBUG) fprintf((FILE*)context, "%04x ", file->info());
1207+
if (verbosity & VERBOSE_DEBUG) fprintf((FILE*)context, "%04llx ", file->info());
12081208
file->print((FILE*)context);
12091209
return DEPOT_OK;
12101210
}

darwinup/Digest.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ void SHA1Digest::digest(unsigned char* md, int fd) {
100100
CC_SHA1_CTX c;
101101
CC_SHA1_Init(&c);
102102

103-
int len;
103+
ssize_t len;
104104
const unsigned int blocklen = 8192;
105105
static uint8_t* block = NULL;
106106
if (block == NULL) {
@@ -111,7 +111,7 @@ void SHA1Digest::digest(unsigned char* md, int fd) {
111111
if (len == 0) { close(fd); break; }
112112
if ((len < 0) && (errno == EINTR)) continue;
113113
if (len < 0) { close(fd); return; }
114-
CC_SHA1_Update(&c, block, (size_t)len);
114+
CC_SHA1_Update(&c, block, (CC_LONG)len);
115115
}
116116
if (len >= 0) {
117117
CC_SHA1_Final(md, &c);
@@ -124,11 +124,11 @@ void SHA1Digest::digest(unsigned char* md, uint8_t* data, uint32_t size) {
124124

125125
SHA1DigestSymlink::SHA1DigestSymlink(const char* filename) {
126126
char link[PATH_MAX];
127-
int res = readlink(filename, link, PATH_MAX);
127+
ssize_t res = readlink(filename, link, PATH_MAX);
128128
if (res == -1) {
129129
fprintf(stderr, "%s:%d: readlink: %s: %s (%d)\n", __FILE__, __LINE__, filename, strerror(errno), errno);
130130
} else {
131-
digest(m_data, (uint8_t*)link, res);
131+
digest(m_data, (uint8_t*)link, (uint32_t)res);
132132
}
133133
}
134134

darwinup/File.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,16 +104,16 @@ File::~File() {
104104

105105
uint64_t File::serial() { return m_serial; }
106106
Archive* File::archive() { return m_archive; }
107-
uint32_t File::info() { return m_info; }
107+
uint64_t File::info() { return m_info; }
108108
const char* File::path() { return m_path; }
109109
mode_t File::mode() { return m_mode; }
110110
uid_t File::uid() { return m_uid; }
111111
gid_t File::gid() { return m_gid; }
112112
off_t File::size() { return m_size; }
113113
Digest* File::digest() { return m_digest; }
114114

115-
void File::info_set(uint32_t flag) { m_info = INFO_SET(m_info, flag); }
116-
void File::info_clr(uint32_t flag) { m_info = INFO_CLR(m_info, flag); }
115+
void File::info_set(uint64_t flag) { m_info = INFO_SET(m_info, flag); }
116+
void File::info_clr(uint64_t flag) { m_info = INFO_CLR(m_info, flag); }
117117
void File::archive(Archive* archive) { m_archive = archive; }
118118

119119
uint32_t File::compare(File* a, File* b) {

0 commit comments

Comments
 (0)