Skip to content

Commit

Permalink
Fix some compile warnings.
Browse files Browse the repository at this point in the history
  • Loading branch information
killing committed Feb 10, 2017
1 parent f93dfb0 commit bc83c3a
Show file tree
Hide file tree
Showing 10 changed files with 15 additions and 164 deletions.
10 changes: 2 additions & 8 deletions common/commit-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,7 @@ seaf_commit_from_data (const char *id, char *data, gsize len)

object = json_loadb (data, len, 0, &jerror);
if (!object) {
if (jerror.text)
seaf_warning ("Failed to load commit json: %s.\n", jerror.text);
else
seaf_warning ("Failed to load commit json.\n");
seaf_warning ("Failed to load commit json: %s.\n", jerror.text);
return NULL;
}
}
Expand Down Expand Up @@ -821,10 +818,7 @@ load_commit (SeafCommitManager *mgr,

object = json_loadb (data, len, 0, &jerror);
if (!object) {
if (jerror.text)
seaf_warning ("Failed to load commit json object: %s.\n", jerror.text);
else
seaf_warning ("Failed to load commit json object.\n");
seaf_warning ("Failed to load commit json object: %s.\n", jerror.text);
goto out;
}
}
Expand Down
20 changes: 4 additions & 16 deletions common/fs-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1042,10 +1042,7 @@ seafile_from_json (const char *id, void *data, int len)
object = json_loadb ((const char *)decompressed, outlen, 0, &error);
g_free (decompressed);
if (!object) {
if (error.text)
seaf_warning ("Failed to load seafile json object: %s.\n", error.text);
else
seaf_warning ("Failed to load seafile json object.\n");
seaf_warning ("Failed to load seafile json object: %s.\n", error.text);
return NULL;
}

Expand Down Expand Up @@ -1515,10 +1512,7 @@ seaf_dir_from_json (const char *dir_id, uint8_t *data, int len)
object = json_loadb ((const char *)decompressed, outlen, 0, &error);
g_free (decompressed);
if (!object) {
if (error.text)
seaf_warning ("Failed to load seafdir json object: %s.\n", error.text);
else
seaf_warning ("Failed to load seafdir json object.\n");
seaf_warning ("Failed to load seafdir json object: %s.\n", error.text);
return NULL;
}

Expand Down Expand Up @@ -1807,10 +1801,7 @@ parse_metadata_type_json (const char *obj_id, uint8_t *data, int len)
object = json_loadb ((const char *)decompressed, outlen, 0, &error);
g_free (decompressed);
if (!object) {
if (error.text)
seaf_warning ("Failed to load fs json object: %s.\n", error.text);
else
seaf_warning ("Failed to load fs json object.\n");
seaf_warning ("Failed to load fs json object: %s.\n", error.text);
return SEAF_METADATA_TYPE_INVALID;
}

Expand Down Expand Up @@ -1863,10 +1854,7 @@ fs_object_from_json (const char *obj_id, uint8_t *data, int len)
object = json_loadb ((const char *)decompressed, outlen, 0, &error);
g_free (decompressed);
if (!object) {
if (error.text)
seaf_warning ("Failed to load fs json object: %s.\n", error.text);
else
seaf_warning ("Failed to load fs json object.\n");
seaf_warning ("Failed to load fs json object: %s.\n", error.text);
return NULL;
}

Expand Down
60 changes: 0 additions & 60 deletions common/index/index.c
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
return 0;
}

static inline size_t estimate_cache_size(size_t ondisk_size, unsigned int entries)
{
long per_entry;

per_entry = sizeof(struct cache_entry) - sizeof(struct ondisk_cache_entry);

/*
* Alignment can cause differences. This should be "alignof", but
* since that's a gcc'ism, just use the size of a pointer.
*/
per_entry += sizeof(void *);
return ondisk_size + entries*per_entry;
}

static int convert_from_disk(struct ondisk_cache_entry *ondisk, struct cache_entry **ce)
{
size_t len;
Expand Down Expand Up @@ -478,20 +464,6 @@ void mark_all_ce_unused(struct index_state *index)
}


static int is_empty_blob_sha1(const unsigned char *sha1)
{
/* static const unsigned char empty_blob_sha1[20] = { */
/* 0xe6,0x9d,0xe2,0x9b,0xb2,0xd1,0xd6,0x43,0x4b,0x8b, */
/* 0x29,0xae,0x77,0x5a,0xd8,0xc2,0xe4,0x8c,0x53,0x91 */
/* }; */

static const unsigned char empty_blob_sha1[20] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
};
return !hashcmp(sha1, empty_blob_sha1);
}

static int ce_match_stat_basic(struct cache_entry *ce, SeafStat *st)
{
unsigned int changed = 0;
Expand Down Expand Up @@ -1949,38 +1921,6 @@ static void ce_smudge_racily_clean_entry(struct cache_entry *ce)
}
#endif

static int ce_write_entry(WriteIndexInfo *info, int fd, struct cache_entry *ce)
{
int size = ondisk_ce_size(ce);
struct ondisk_cache_entry *ondisk = calloc(1, size);
char *name;
int result;

ondisk->ctime.sec = htonl((unsigned int)ce->ce_ctime.sec);
ondisk->mtime.sec = htonl((unsigned int)ce->ce_mtime.sec);
ondisk->dev = htonl(ce->ce_dev);
ondisk->ino = htonl(ce->ce_ino);
ondisk->mode = htonl(ce->ce_mode);
ondisk->uid = htonl(ce->ce_uid);
ondisk->gid = htonl(ce->ce_gid);
ondisk->size = hton64(ce->ce_size);
hashcpy(ondisk->sha1, ce->sha1);
ondisk->flags = htons(ce->ce_flags);
/* if (ce->ce_flags & CE_EXTENDED) { */
/* struct ondisk_cache_entry_extended *ondisk2; */
/* ondisk2 = (struct ondisk_cache_entry_extended *)ondisk; */
/* ondisk2->flags2 = htons((ce->ce_flags & CE_EXTENDED_FLAGS) >> 16); */
/* name = ondisk2->name; */
/* } */
/* else */
name = ondisk->name;
memcpy(name, ce->name, ce_namelen(ce));

result = ce_write(info, fd, ondisk, size);
free(ondisk);
return result;
}

static int ce_write_entry2(WriteIndexInfo *info, int fd, struct cache_entry *ce)
{
int size = ondisk_ce_size2(ce);
Expand Down
12 changes: 2 additions & 10 deletions daemon/clone-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -554,11 +554,7 @@ load_more_info_cb (sqlite3_stmt *stmt, void *data)
more_info = (const char *)sqlite3_column_text (stmt, 0);
object = json_loads (more_info, 0, &jerror);
if (!object) {
if (jerror.text)
seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text);
else
seaf_warning ("Failed to load more sync info from json.\n");

seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text);
return FALSE;
}

Expand Down Expand Up @@ -1323,11 +1319,7 @@ add_task_common (SeafCloneManager *mgr,

object = json_loads (more_info, 0, &jerror);
if (!object) {
if (jerror.text)
seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text);
else
seaf_warning ("Failed to load more sync info from json.\n");

seaf_warning ("Failed to load more sync info from json: %s.\n", jerror.text);
clone_task_free (task);
return NULL;
}
Expand Down
32 changes: 0 additions & 32 deletions daemon/merge-recursive.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,38 +381,6 @@ static int remove_file(struct merge_options *o, int clean,
return 0;
}

inline static int file_exists(const char *f)
{
SeafStat sb;
return (seaf_stat (f, &sb) == 0);
}

#if 0
static int would_lose_untracked(struct index_state *index, const char *path, const char *real_path)
{
int pos = index_name_pos(index, path, strlen(path));

if (pos < 0)
pos = -1 - pos;
while (pos < index->cache_nr &&
!strcmp(path, index->cache[pos]->name)) {
/*
* If stage #0, it is definitely tracked.
* If it has stage #2 then it was tracked
* before this merge started. All other
* cases the path was not tracked.
*/
switch (ce_stage(index->cache[pos])) {
case 0:
case 2:
return 0;
}
pos++;
}
return file_exists(real_path);
}
#endif

static int create_leading_directories(int base_len,
const char *path, char **new_path,
const char *conflict_suffix,
Expand Down
2 changes: 1 addition & 1 deletion daemon/processors/sendfs-v2-proc.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,6 +200,7 @@ calculate_send_object_list (void *vdata)
TransferTask *task = proc->tx_task;

SeafBranch *local = NULL, *master = NULL;
SeafCommit *local_head = NULL, *master_head = NULL;
local = seaf_branch_manager_get_branch (seaf->branch_mgr, task->repo_id, "local");
if (!local) {
seaf_warning ("Branch local not found for repo %.8s.\n", task->repo_id);
Expand All @@ -213,7 +214,6 @@ calculate_send_object_list (void *vdata)
goto out;
}

SeafCommit *local_head = NULL, *master_head = NULL;
local_head = seaf_commit_manager_get_commit (seaf->commit_mgr,
task->repo_id, task->repo_version,
local->commit_id);
Expand Down
23 changes: 2 additions & 21 deletions daemon/repo-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -1084,6 +1084,7 @@ seaf_repo_manager_is_ignored_hidden_file (const char *filename)
return FALSE;
}

#ifdef WIN32
static inline gboolean
has_trailing_space_or_period (const char *path)
{
Expand All @@ -1094,6 +1095,7 @@ has_trailing_space_or_period (const char *path)

return FALSE;
}
#endif

typedef enum IgnoreReason {
IGNORE_REASON_END_SPACE_PERIOD = 0,
Expand Down Expand Up @@ -2139,8 +2141,6 @@ add_path_to_index (SeafRepo *repo, struct index_state *istate,
GList **scanned_dirs, gint64 *total_size, GQueue **remain_files,
LockedFileSet *fset)
{
SeafStat st;

/* If we've recursively scanned the parent directory, don't need to scan
* any files under it any more.
*/
Expand Down Expand Up @@ -4167,13 +4167,6 @@ print_index (struct index_state *istate)
}
#endif

static inline void
print_time (const char *desc, GTimeVal *s, GTimeVal *e)
{
seaf_message ("%s: %lu\n", desc,
(e->tv_sec*G_USEC_PER_SEC+e->tv_usec - (s->tv_sec*G_USEC_PER_SEC+s->tv_usec))/1000);
}

char *
seaf_repo_index_commit (SeafRepo *repo, const char *desc,
gboolean is_force_commit,
Expand Down Expand Up @@ -7485,18 +7478,6 @@ save_repo_property (SeafRepoManager *manager,
pthread_mutex_unlock (&manager->priv->db_lock);
}

inline static gboolean is_peer_relay (const char *peer_id)
{
CcnetPeer *peer = ccnet_get_peer(seaf->ccnetrpc_client, peer_id);

if (!peer)
return FALSE;

gboolean is_relay = string_list_is_exists(peer->role_list, "MyRelay");
g_object_unref (peer);
return is_relay;
}

int
seaf_repo_manager_set_repo_relay_id (SeafRepoManager *mgr,
SeafRepo *repo,
Expand Down
6 changes: 4 additions & 2 deletions daemon/sync-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -3331,8 +3331,10 @@ seaf_sync_manager_get_path_sync_status (SeafSyncManager *mgr,

/* If the repo is in error, all files in it should show no sync status. */
sync_info = get_sync_info (mgr, repo_id);
if (sync_info && sync_info->in_error)
return SYNC_STATUS_NONE;
if (sync_info && sync_info->in_error) {
ret = SYNC_STATUS_NONE;
goto out;
}

pthread_mutex_lock (&mgr->priv->paths_lock);

Expand Down
12 changes: 0 additions & 12 deletions daemon/transfer-mgr.c
Original file line number Diff line number Diff line change
Expand Up @@ -406,18 +406,6 @@ transfer_task_with_proc_failure (TransferTask *task,
}
}

inline static gboolean is_peer_relay (const char *peer_id)
{
CcnetPeer *peer = ccnet_get_peer(seaf->ccnetrpc_client, peer_id);

if (!peer)
return FALSE;

gboolean is_relay = string_list_is_exists(peer->role_list, "MyRelay");
g_object_unref (peer);
return is_relay;
}

/*
* Transfer Manager.
*/
Expand Down
2 changes: 0 additions & 2 deletions daemon/wt-monitor-macos.c
Original file line number Diff line number Diff line change
Expand Up @@ -236,11 +236,9 @@ stream_callback (ConstFSEventStreamRef streamRef,
const FSEventStreamEventId eventIds[])
{
RepoWatchInfo *info;
char *repo_id;
SeafWTMonitor *monitor = (SeafWTMonitor *)clientCallBackInfo;
SeafWTMonitorPriv *priv = monitor->priv;
char **paths = (char **)eventPaths;
char *dir;

info = g_hash_table_lookup (priv->info_hash, (gpointer)(long)streamRef);
if (!info) {
Expand Down

0 comments on commit bc83c3a

Please sign in to comment.