ANDROID: Changed type-casting in packagelist management
Fixed existing type-casting in packagelist management code. All warnings at compile time were taken care of. Change-Id: I1ea97786d1d1325f31b9f09ae966af1f896a2af5 Signed-off-by: Daniel Campello <campello@google.com>
This commit is contained in:
parent
71b8d35b08
commit
ca275513ce
1 changed files with 21 additions and 19 deletions
|
@ -31,7 +31,7 @@
|
|||
struct hashtable_entry {
|
||||
struct hlist_node hlist;
|
||||
void *key;
|
||||
int value;
|
||||
unsigned int value;
|
||||
};
|
||||
|
||||
struct packagelist_data {
|
||||
|
@ -54,7 +54,7 @@ static const char* const kpackageslist_file = "/data/system/packages.list";
|
|||
/* Supplementary groups to execute with */
|
||||
static const gid_t kgroups[1] = { AID_PACKAGE_INFO };
|
||||
|
||||
static unsigned int str_hash(void *key) {
|
||||
static unsigned int str_hash(const char *key) {
|
||||
int i;
|
||||
unsigned int h = strlen(key);
|
||||
char *data = (char *)key;
|
||||
|
@ -66,13 +66,13 @@ static unsigned int str_hash(void *key) {
|
|||
return h;
|
||||
}
|
||||
|
||||
static int contain_appid_key(struct packagelist_data *pkgl_dat, void *appid) {
|
||||
static int contain_appid_key(struct packagelist_data *pkgl_dat, unsigned int appid) {
|
||||
struct hashtable_entry *hash_cur;
|
||||
|
||||
hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist, (unsigned int)appid)
|
||||
|
||||
if (appid == hash_cur->key)
|
||||
hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist, appid)
|
||||
if ((void *)(uintptr_t)appid == hash_cur->key)
|
||||
return 1;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -89,7 +89,7 @@ int get_caller_has_rw_locked(void *pkgl_id, derive_t derive) {
|
|||
|
||||
appid = multiuser_get_app_id(from_kuid(&init_user_ns, current_fsuid()));
|
||||
mutex_lock(&pkgl_dat->hashtable_lock);
|
||||
ret = contain_appid_key(pkgl_dat, (void *)appid);
|
||||
ret = contain_appid_key(pkgl_dat, appid);
|
||||
mutex_unlock(&pkgl_dat->hashtable_lock);
|
||||
return ret;
|
||||
}
|
||||
|
@ -98,7 +98,7 @@ appid_t get_appid(void *pkgl_id, const char *app_name)
|
|||
{
|
||||
struct packagelist_data *pkgl_dat = (struct packagelist_data *)pkgl_id;
|
||||
struct hashtable_entry *hash_cur;
|
||||
unsigned int hash = str_hash((void *)app_name);
|
||||
unsigned int hash = str_hash(app_name);
|
||||
appid_t ret_id;
|
||||
|
||||
//printk(KERN_INFO "sdcardfs: %s: %s, %u\n", __func__, (char *)app_name, hash);
|
||||
|
@ -171,7 +171,9 @@ int open_flags_to_access_mode(int open_flags) {
|
|||
}
|
||||
}
|
||||
|
||||
static int insert_str_to_int(struct packagelist_data *pkgl_dat, void *key, int value) {
|
||||
static int insert_str_to_int(struct packagelist_data *pkgl_dat, char *key,
|
||||
unsigned int value)
|
||||
{
|
||||
struct hashtable_entry *hash_cur;
|
||||
struct hashtable_entry *new_entry;
|
||||
unsigned int hash = str_hash(key);
|
||||
|
@ -198,14 +200,15 @@ static void remove_str_to_int(struct hashtable_entry *h_entry) {
|
|||
kmem_cache_free(hashtable_entry_cachep, h_entry);
|
||||
}
|
||||
|
||||
static int insert_int_to_null(struct packagelist_data *pkgl_dat, void *key, int value) {
|
||||
static int insert_int_to_null(struct packagelist_data *pkgl_dat, unsigned int key,
|
||||
unsigned int value)
|
||||
{
|
||||
struct hashtable_entry *hash_cur;
|
||||
struct hashtable_entry *new_entry;
|
||||
|
||||
//printk(KERN_INFO "sdcardfs: %s: %d: %d\n", __func__, (int)key, value);
|
||||
hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist,
|
||||
(unsigned int)key) {
|
||||
if (key == hash_cur->key) {
|
||||
hash_for_each_possible(pkgl_dat->appid_with_rw, hash_cur, hlist, key) {
|
||||
if ((void *)(uintptr_t)key == hash_cur->key) {
|
||||
hash_cur->value = value;
|
||||
return 0;
|
||||
}
|
||||
|
@ -213,10 +216,9 @@ static int insert_int_to_null(struct packagelist_data *pkgl_dat, void *key, int
|
|||
new_entry = kmem_cache_alloc(hashtable_entry_cachep, GFP_KERNEL);
|
||||
if (!new_entry)
|
||||
return -ENOMEM;
|
||||
new_entry->key = key;
|
||||
new_entry->key = (void *)(uintptr_t)key;
|
||||
new_entry->value = value;
|
||||
hash_add(pkgl_dat->appid_with_rw, &new_entry->hlist,
|
||||
(unsigned int)new_entry->key);
|
||||
hash_add(pkgl_dat->appid_with_rw, &new_entry->hlist, key);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -260,7 +262,7 @@ static int read_package_list(struct packagelist_data *pkgl_dat) {
|
|||
|
||||
while ((read_amount = sys_read(fd, pkgl_dat->read_buf,
|
||||
sizeof(pkgl_dat->read_buf))) > 0) {
|
||||
int appid;
|
||||
unsigned int appid;
|
||||
char *token;
|
||||
int one_line_len = 0;
|
||||
int additional_read;
|
||||
|
@ -277,7 +279,7 @@ static int read_package_list(struct packagelist_data *pkgl_dat) {
|
|||
if (additional_read > 0)
|
||||
sys_lseek(fd, -additional_read, SEEK_CUR);
|
||||
|
||||
if (sscanf(pkgl_dat->read_buf, "%s %d %*d %*s %*s %s",
|
||||
if (sscanf(pkgl_dat->read_buf, "%s %u %*d %*s %*s %s",
|
||||
pkgl_dat->app_name_buf, &appid,
|
||||
pkgl_dat->gids_buf) == 3) {
|
||||
ret = insert_str_to_int(pkgl_dat, pkgl_dat->app_name_buf, appid);
|
||||
|
@ -291,7 +293,7 @@ static int read_package_list(struct packagelist_data *pkgl_dat) {
|
|||
while (token != NULL) {
|
||||
if (!kstrtoul(token, 10, &ret_gid) &&
|
||||
(ret_gid == pkgl_dat->write_gid)) {
|
||||
ret = insert_int_to_null(pkgl_dat, (void *)appid, 1);
|
||||
ret = insert_int_to_null(pkgl_dat, appid, 1);
|
||||
if (ret) {
|
||||
sys_close(fd);
|
||||
mutex_unlock(&pkgl_dat->hashtable_lock);
|
||||
|
|
Loading…
Reference in a new issue