Skip to content

Commit 462cc2b

Browse files
committed
Set new process-related fields to zero during conversion
1 parent 2b674f9 commit 462cc2b

1 file changed

Lines changed: 29 additions & 2 deletions

File tree

atopconvert.c

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,33 @@ tgen_to_22(void *old, void *new, count_t oldsize, count_t newsize)
218218
g22->vpid = 0;
219219
}
220220

221+
void
222+
tcpu_to_26(void *old, void *new, count_t oldsize, count_t newsize)
223+
{
224+
// unused values appear not to be zeroed in version 2.5
225+
//
226+
struct cpu_25 *c25 = old;
227+
struct cpu_26 *c26 = new;
228+
229+
memcpy(c26, c25, sizeof *c26); // copy entire struct
230+
231+
memset(&(c26->wchan), 0, sizeof c26->wchan);
232+
c26->rundelay = 0;
233+
}
234+
235+
void
236+
tmem_to_26(void *old, void *new, count_t oldsize, count_t newsize)
237+
{
238+
// unused values appear not to be zeroed in version 2.5
239+
//
240+
struct mem_25 *m25 = old;
241+
struct mem_26 *m26 = new;
242+
243+
memcpy(m26, m25, sizeof *m26); // copy entire struct
244+
245+
m26->vlock = 0;
246+
}
247+
221248
///////////////////////////////////////////////////////////////
222249
// conversion definition for various structs in sstat and tstat
223250
//
@@ -480,11 +507,11 @@ struct convertall {
480507
{sizeof(struct gen_26),
481508
STROFFSET(&tstat_26.gen, &tstat_26), justcopy},
482509
{sizeof(struct cpu_26),
483-
STROFFSET(&tstat_26.cpu, &tstat_26), justcopy},
510+
STROFFSET(&tstat_26.cpu, &tstat_26), tcpu_to_26},
484511
{sizeof(struct dsk_26),
485512
STROFFSET(&tstat_26.dsk, &tstat_26), justcopy},
486513
{sizeof(struct mem_26),
487-
STROFFSET(&tstat_26.mem, &tstat_26), justcopy},
514+
STROFFSET(&tstat_26.mem, &tstat_26), tmem_to_26},
488515
{sizeof(struct net_26),
489516
STROFFSET(&tstat_26.net, &tstat_26), justcopy},
490517
{sizeof(struct gpu_26),

0 commit comments

Comments
 (0)