Permalink
Browse files

all: fix implicit integer conversions.

git-svn-id: https://svn.macosforge.org/repository/darwinbuild/trunk@1057 10a61168-4876-4dac-953b-31e694342555
  • Loading branch information...
mwwa committed Apr 24, 2013
1 parent 5b2b80b commit d3ea7f7e061ea8654a83f1fd58ff7cc7cf7a7aa0
@@ -1,5 +1,8 @@
Darwin Build Scripts Change History
-----------------------------------
Release 35 [24-Apr-2013]
- all: fix implicit integer conversions.

Release 34.1 [14-Mar-2013]
Release 34 [12-Mar-2013]
- darwintrace: avoid snprintf(3); manually construct log messages.
@@ -3404,6 +3404,7 @@
GCC_MODEL_TUNING = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3550,6 +3551,7 @@
GCC_MODEL_TUNING = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -3585,6 +3587,7 @@
GCC_MODEL_TUNING = "";
GCC_TREAT_IMPLICIT_FUNCTION_DECLARATIONS_AS_ERRORS = YES;
GCC_TREAT_WARNINGS_AS_ERRORS = YES;
GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
GCC_WARN_ABOUT_MISSING_FIELD_INITIALIZERS = YES;
GCC_WARN_ABOUT_MISSING_NEWLINE = YES;
GCC_WARN_ABOUT_RETURN_TYPE = YES;
@@ -84,7 +84,7 @@ char* calculate_digest(int fd) {
if (len == 0) { close(fd); break; }
if ((len < 0) && (errno == EINTR)) continue;
if (len < 0) { close(fd); return NULL; }
CC_SHA1_Update(&c, block, (size_t)len);
CC_SHA1_Update(&c, block, (CC_LONG)len);
}

CC_SHA1_Final(md, &c);
@@ -80,7 +80,7 @@ static char* calculate_digest(int fd) {
if (len == 0) { close(fd); break; }
if ((len < 0) && (errno == EINTR)) continue;
if (len < 0) { close(fd); return NULL; }
CC_SHA1_Update(&c, block, (size_t)len);
CC_SHA1_Update(&c, block, (CC_LONG)len);
}

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

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

// Filename
filename[0] = 0;
@@ -105,7 +105,7 @@ int DarwinupDatabase::set_archive_active(uint64_t serial, uint64_t* active) {
}

int DarwinupDatabase::update_archive(uint64_t serial, uuid_t uuid, const char* name,
time_t date_added, uint32_t active, uint32_t info,
time_t date_added, uint32_t active, uint64_t info,
const char* build) {
this->clear_last_archive();
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
build);
}

uint64_t DarwinupDatabase::insert_archive(uuid_t uuid, uint32_t info, const char* name,
uint64_t DarwinupDatabase::insert_archive(uuid_t uuid, uint64_t info, const char* name,
time_t date_added, const char* build) {

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

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

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

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

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

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

int res = this->insert(this->m_files_table,
@@ -73,9 +73,9 @@ struct DarwinupDatabase : Database {
int activate_archive(uint64_t serial);
int deactivate_archive(uint64_t serial);
int update_archive(uint64_t serial, uuid_t uuid, const char* name,
time_t date_added, uint32_t active, uint32_t info,
time_t date_added, uint32_t active, uint64_t info,
const char* build);
uint64_t insert_archive(uuid_t uuid, uint32_t info, const char* name,
uint64_t insert_archive(uuid_t uuid, uint64_t info, const char* name,
time_t date, const char* build);
int delete_empty_archives();
int delete_archive(Archive* archive);
@@ -90,9 +90,9 @@ struct DarwinupDatabase : Database {
uint64_t** serial);
int get_files(uint8_t*** data, uint32_t* count, Archive* archive, bool reverse);
int file_offset(int column);
int update_file(uint64_t serial, Archive* archive, uint32_t info, mode_t mode,
int update_file(uint64_t serial, Archive* archive, uint64_t info, mode_t mode,
uid_t uid, gid_t gid, Digest* digest, const char* path);
uint64_t insert_file(uint32_t info, mode_t mode, uid_t uid, gid_t gid,
uint64_t insert_file(uint64_t info, mode_t mode, uid_t uid, gid_t gid,
Digest* digest, Archive* archive, const char* path);
int delete_file(uint64_t serial);
int delete_file(File* file);
@@ -606,7 +606,7 @@ int Database::sql(const char* name, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
char* query = sqlite3_vmprintf(fmt, args);
int res = sqlite3_prepare_v2(m_db, query, strlen(query), &stmt, NULL);
int res = sqlite3_prepare_v2(m_db, query, (int)strlen(query), &stmt, NULL);
va_end(args);
if (res != SQLITE_OK) {
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) {
current += this->store_column(stmt, i, current);
}
if (used) {
*used = current - output;
*used = (uint32_t)(current - output);
}
}

@@ -1001,7 +1001,7 @@ int Depot::uninstall_file(File* file, void* ctx) {
context->depot->m_modified_extensions = true;
}
}
uint32_t info = preceding->info();
uint64_t info = preceding->info();
if (INFO_TEST(info, FILE_INFO_NO_ENTRY | FILE_INFO_ROLLBACK_DATA) &&
!INFO_TEST(info, FILE_INFO_BASE_SYSTEM)) {
if (!dryrun && res == 0) {
@@ -1198,13 +1198,13 @@ int Depot::list(int count, char** args) {
if (archive) res = this->list_archive(archive, stdout);
}
}

return res;
}

int Depot::print_file(File* file, void* context) {
extern uint32_t verbosity;
if (verbosity & VERBOSE_DEBUG) fprintf((FILE*)context, "%04x ", file->info());
if (verbosity & VERBOSE_DEBUG) fprintf((FILE*)context, "%04llx ", file->info());
file->print((FILE*)context);
return DEPOT_OK;
}
@@ -100,7 +100,7 @@ void SHA1Digest::digest(unsigned char* md, int fd) {
CC_SHA1_CTX c;
CC_SHA1_Init(&c);

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

SHA1DigestSymlink::SHA1DigestSymlink(const char* filename) {
char link[PATH_MAX];
int res = readlink(filename, link, PATH_MAX);
ssize_t res = readlink(filename, link, PATH_MAX);
if (res == -1) {
fprintf(stderr, "%s:%d: readlink: %s: %s (%d)\n", __FILE__, __LINE__, filename, strerror(errno), errno);
} else {
digest(m_data, (uint8_t*)link, res);
digest(m_data, (uint8_t*)link, (uint32_t)res);
}
}

@@ -104,16 +104,16 @@ File::~File() {

uint64_t File::serial() { return m_serial; }
Archive* File::archive() { return m_archive; }
uint32_t File::info() { return m_info; }
uint64_t File::info() { return m_info; }
const char* File::path() { return m_path; }
mode_t File::mode() { return m_mode; }
uid_t File::uid() { return m_uid; }
gid_t File::gid() { return m_gid; }
off_t File::size() { return m_size; }
Digest* File::digest() { return m_digest; }

void File::info_set(uint32_t flag) { m_info = INFO_SET(m_info, flag); }
void File::info_clr(uint32_t flag) { m_info = INFO_CLR(m_info, flag); }
void File::info_set(uint64_t flag) { m_info = INFO_SET(m_info, flag); }
void File::info_clr(uint64_t flag) { m_info = INFO_CLR(m_info, flag); }
void File::archive(Archive* archive) { m_archive = archive; }

uint32_t File::compare(File* a, File* b) {
@@ -130,9 +130,9 @@ struct File {
virtual uint64_t serial();

// FILE_INFO flags.
virtual uint32_t info();
virtual void info_set(uint32_t);
virtual void info_clr(uint32_t);
virtual uint64_t info();
virtual void info_set(uint64_t);
virtual void info_clr(uint64_t);

// Pointer to the Archive this file belongs to.
virtual Archive* archive();
@@ -193,7 +193,7 @@ struct File {
protected:

uint64_t m_serial;
uint32_t m_info;
uint64_t m_info;
Archive* m_archive;
char* m_path;
mode_t m_mode;
@@ -227,7 +227,7 @@ sqlite3_stmt* Table::update(sqlite3* db) {
strlcat(m_update_sql, ";", size);

// prepare
int res = sqlite3_prepare_v2(db, m_update_sql, strlen(m_update_sql), &m_prepared_update, NULL);
int res = sqlite3_prepare_v2(db, m_update_sql, (int)strlen(m_update_sql), &m_prepared_update, NULL);
if (res != SQLITE_OK) {
fprintf(stderr, "Error: unable to prepare update statement for table: %s \n", m_name);
return NULL;
@@ -281,7 +281,7 @@ sqlite3_stmt* Table::insert(sqlite3* db) {
IF_SQL("insert sql: %s \n", m_insert_sql);

// prepare
int res = sqlite3_prepare_v2(db, m_insert_sql, strlen(m_insert_sql), &m_prepared_insert, NULL);
int res = sqlite3_prepare_v2(db, m_insert_sql, (int)strlen(m_insert_sql), &m_prepared_insert, NULL);
if (res != SQLITE_OK) {
fprintf(stderr, "Error: unable to prepare insert statement for table: %s \n", m_name);
return NULL;
@@ -319,7 +319,7 @@ sqlite3_stmt* Table::del(sqlite3* db) {
strlcat(m_delete_sql, ";", size);

// prepare
int res = sqlite3_prepare_v2(db, m_delete_sql, strlen(m_delete_sql), &m_prepared_delete, NULL);
int res = sqlite3_prepare_v2(db, m_delete_sql, (int)strlen(m_delete_sql), &m_prepared_delete, NULL);
if (res != SQLITE_OK) {
fprintf(stderr, "Error: unable to prepare delete statement for table: %s \n", m_name);
return NULL;
@@ -347,7 +347,7 @@ sqlite3_stmt* Table::del(sqlite3* db) {
}

#define __prepare_stmt \
int res = sqlite3_prepare_v2(db, query, size, pps, NULL); \
int res = sqlite3_prepare_v2(db, query, (int)size, pps, NULL); \
free(query); \
if (res != SQLITE_OK) { \
fprintf(stderr, "Error: unable to prepare statement: %s\n", \
@@ -38,7 +38,7 @@ int fts_compare(const FTSENT **a, const FTSENT **b) {
return strcmp((*a)->fts_name, (*b)->fts_name);
}

int ftsent_filename(FTSENT* ent, char* filename, size_t bufsiz) {
size_t ftsent_filename(FTSENT* ent, char* filename, size_t bufsiz) {
if (ent == NULL) return 0;
if (ent->fts_level > 1) {
bufsiz = ftsent_filename(ent->fts_parent, filename, bufsiz);
@@ -432,7 +432,7 @@ int update_xpc_services_cache(const char* path) {

#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 1060
int build_number_for_path(char** build, const char* path) {
int res = 0;
ssize_t res = 0;
char system[PATH_MAX];
char* base;

@@ -461,8 +461,8 @@ int build_number_for_path(char** build, const char* path) {
int pfd[2];
res = pipe(pfd);
if (res) {
fprintf(stderr, "Error: (%d) failed to create pipe.\n", res);
return res;
fprintf(stderr, "Error: (%ld) failed to create pipe.\n", res);
return (int)res;
}
exec_with_args_pipe(args, pfd[1]);

@@ -476,11 +476,11 @@ int build_number_for_path(char** build, const char* path) {
}
close(pfd[0]);

if (res == 0) return res; // success
if (res == 0) return (int)res; // success

if (res == -1) {
fprintf(stderr, "Error: failed to read build from plist.\n");
return res;
return (int)res;
}

return -1;
@@ -59,7 +59,7 @@ const uint32_t VERBOSE_SQL = 0x4;
#define IF_SQL(...) do { extern uint32_t verbosity; if (verbosity & VERBOSE_SQL) fprintf(stderr, "DEBUG: " __VA_ARGS__); } while (0)

int fts_compare(const FTSENT **a, const FTSENT **b);
int ftsent_filename(FTSENT* ent, char* filename, size_t bufsiz);
size_t ftsent_filename(FTSENT* ent, char* filename, size_t bufsiz);
int mkdir_p(const char* path);
int remove_directory(const char* path);
int is_directory(const char* path);
@@ -93,8 +93,8 @@ void __data_hex(FILE* f, uint8_t* data, uint32_t size);
// print a horizontal line to stdout
void hr();

inline int INFO_TEST(uint32_t word, uint32_t flag) { return ((word & flag) != 0); }
inline int INFO_SET(uint32_t word, uint32_t flag) { return (word | flag); }
inline int INFO_CLR(uint32_t word, uint32_t flag) { return (word & (~flag)); }
inline bool INFO_TEST(uint64_t word, uint64_t flag) { return ((word & flag) != 0); }
inline uint64_t INFO_SET(uint64_t word, uint64_t flag) { return (word | flag); }
inline uint64_t INFO_CLR(uint64_t word, uint64_t flag) { return (word & (~flag)); }

#endif
@@ -621,7 +621,7 @@ int DBSetPropData(CFStringRef build, CFStringRef project, CFStringRef property,
sqlite3_bind_text(stmt, i++, cbuild, -1, NULL);
if (project) sqlite3_bind_text(stmt, i++, cproj, -1, NULL);
sqlite3_bind_text(stmt, i++, cprop, -1, NULL);
sqlite3_bind_blob(stmt, i++, CFDataGetBytePtr(value), CFDataGetLength(value), NULL);
sqlite3_bind_blob(stmt, i++, CFDataGetBytePtr(value), (int)CFDataGetLength(value), NULL);
res = sqlite3_step(stmt);
if (res != SQLITE_DONE) fprintf(stderr, "%s:%d result = %d\n", __FILE__, __LINE__, res);
sqlite3_finalize(stmt);
Oops, something went wrong.

0 comments on commit d3ea7f7

Please sign in to comment.