Skip to content

Commit

Permalink
fix stats decremented with unsigned values
Browse files Browse the repository at this point in the history
Reported by Coverity CID #200104, #200030, #200096, #200091, #200090,
 #200074, #200073, #200049, #200039, #200035, #200032, #200009,
 #200003, #199998, #199996, #199991, #199988, #199986, #199985,
 #199982, #199977, #199970, #199964, #199963, #199960, #199952,
 #199948, #199945, #199941, #199938, #199934, #199923, #199920
 #199913, #199900, #199896

(cherry picked from commit 0d31e6b)
  • Loading branch information
razvancrainea committed Jul 3, 2019
1 parent 065c924 commit d14a4ac
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions mem/hp_malloc_stats.c
Expand Up @@ -225,9 +225,9 @@ void hp_init_rpm_statistics(struct hp_block *hpb)
rpm_rused->flags |= STAT_NO_RESET;
rpm_frags->flags |= STAT_NO_RESET;
#endif
update_stat(rpm_used, hpb->used);
update_stat(rpm_rused, hpb->real_used);
update_stat(rpm_frags, hpb->total_fragments);
update_stat(rpm_used, (int)hpb->used);
update_stat(rpm_rused, (int)hpb->real_used);
update_stat(rpm_frags, (int)hpb->total_fragments);

LM_DBG("initializing atomic rpm statistics: "
"[ us: %ld | rus: %ld | frags: %ld ]\n", hpb->used, hpb->real_used, hpb->total_fragments);
Expand Down
8 changes: 4 additions & 4 deletions mem/hp_malloc_stats.h
Expand Up @@ -92,8 +92,8 @@ unsigned long hp_rpm_get_frags(struct hp_block *hpb);
#else /* HP_MALLOC_FAST_STATS */
#define update_stats_shm_frag_attach(frag) \
do { \
update_stat(shm_used, -(frag)->size); \
update_stat(shm_rused, -((frag)->size + FRAG_OVERHEAD)); \
update_stat(shm_used, -(int)(frag)->size); \
update_stat(shm_rused, -(int)((frag)->size + FRAG_OVERHEAD)); \
} while (0)

#define update_stats_shm_frag_detach(frag) \
Expand All @@ -111,8 +111,8 @@ unsigned long hp_rpm_get_frags(struct hp_block *hpb);

#define update_stats_rpm_frag_attach(frag) \
do { \
update_stat(rpm_used, -(frag)->size); \
update_stat(rpm_rused, -((frag)->size + FRAG_OVERHEAD)); \
update_stat(rpm_used, -(int)(frag)->size); \
update_stat(rpm_rused, -(int)((frag)->size + FRAG_OVERHEAD)); \
} while (0)

#define update_stats_rpm_frag_detach(frag) \
Expand Down

0 comments on commit d14a4ac

Please sign in to comment.