procfs: use length from snprintf instead of recomputing
Change-Id: I75ba4cf5c2e94798d183728c11bb34032cdddf5a
This commit is contained in:
committed by
Masamichi Takagi
parent
201fa7fb55
commit
a032dc3d1b
@ -313,8 +313,8 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
int cpu;
|
||||
|
||||
for (cpu = 0; cpu < num_processors; ++cpu) {
|
||||
snprintf(buf, count, "cpu%d\n", cpu);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0)
|
||||
ans = snprintf(buf, count, "cpu%d\n", cpu);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0)
|
||||
goto err;
|
||||
}
|
||||
ans = 0;
|
||||
@ -325,7 +325,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
ans = ihk_mc_show_cpuinfo(buf, count, 0, &eof);
|
||||
if (ans < 0)
|
||||
goto err;
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0)
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0)
|
||||
goto err;
|
||||
ans = 0;
|
||||
goto end;
|
||||
@ -416,7 +416,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
* address perms offset dev inode pathname
|
||||
* 08048000-08056000 r-xp 00000000 03:0c 64593 /usr/sbin/gpm
|
||||
*/
|
||||
snprintf(buf, count,
|
||||
ans = snprintf(buf, count,
|
||||
"%012lx-%012lx %s%s%s%s %lx %lx:%lx %d\t\t\t%s\n",
|
||||
range->start, range->end,
|
||||
range->flag & VR_PROT_READ ? "r" : "-",
|
||||
@ -442,7 +442,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
""
|
||||
);
|
||||
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
ihk_mc_spinlock_unlock_noirq(&vm->memory_range_lock);
|
||||
goto err;
|
||||
}
|
||||
@ -552,7 +552,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
state = "T (tracing stop)";
|
||||
else if (proc->status == PS_EXITED)
|
||||
state = "Z (zombie)";
|
||||
sprintf(buf,
|
||||
ans = snprintf(buf, count,
|
||||
"Pid:\t%d\n"
|
||||
"Uid:\t%d\t%d\t%d\t%d\n"
|
||||
"Gid:\t%d\t%d\t%d\t%d\n"
|
||||
@ -563,27 +563,30 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
proc->rgid, proc->egid, proc->sgid, proc->fsgid,
|
||||
state,
|
||||
(lockedsize + 1023) >> 10);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
goto err;
|
||||
}
|
||||
|
||||
sprintf(buf, "Cpus_allowed:\t%s\n", cpu_bitmask);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
ans = snprintf(buf, count, "Cpus_allowed:\t%s\n", cpu_bitmask);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
kfree(bitmasks);
|
||||
goto err;
|
||||
}
|
||||
sprintf(buf, "Cpus_allowed_list:\t%s\n", cpu_list);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
ans = snprintf(buf, count, "Cpus_allowed_list:\t%s\n",
|
||||
cpu_list);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
kfree(bitmasks);
|
||||
goto err;
|
||||
}
|
||||
sprintf(buf, "Mems_allowed:\t%s\n", numa_bitmask);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
ans = snprintf(buf, count, "Mems_allowed:\t%s\n",
|
||||
numa_bitmask);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
kfree(bitmasks);
|
||||
goto err;
|
||||
}
|
||||
sprintf(buf, "Mems_allowed_list:\t%s\n", numa_list);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0) {
|
||||
ans = snprintf(buf, count, "Mems_allowed_list:\t%s\n",
|
||||
numa_list);
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0) {
|
||||
kfree(bitmasks);
|
||||
goto err;
|
||||
}
|
||||
@ -680,7 +683,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
* cnswap exit_signal processor rt_priority
|
||||
* policy delayacct_blkio_ticks guest_time cguest_time
|
||||
*/
|
||||
ans = sprintf(buf,
|
||||
ans = snprintf(buf, count,
|
||||
"%d (%s) %c %d " // pid...
|
||||
"%d %d %d %d " // pgrp...
|
||||
"%u %lu %lu %lu " // flags...
|
||||
@ -705,7 +708,7 @@ int process_procfs_request(struct ikc_scd_packet *rpacket)
|
||||
0, 0LL, 0L, 0L // policy...
|
||||
);
|
||||
|
||||
if (buf_add(&buf_top, &buf_cur, buf, strlen(buf)) < 0)
|
||||
if (buf_add(&buf_top, &buf_cur, buf, ans) < 0)
|
||||
goto err;
|
||||
ans = 0;
|
||||
goto end;
|
||||
|
||||
Reference in New Issue
Block a user