static int lock_on_cpu(int cpu)
{
- cpu_set_t cpu_mask;
-
- CPU_ZERO(&cpu_mask);
- CPU_SET(cpu, &cpu_mask);
- if (sched_setaffinity(0, sizeof(cpu_mask), &cpu_mask) < 0)
+ cpu_set_t * cpu_mask;
+ size_t size;
+ cpu_mask = CPU_ALLOC(ncpus);
+ size = CPU_ALLOC_SIZE(ncpus);
+
+ CPU_ZERO_S(size, cpu_mask);
+ CPU_SET_S(cpu, size, cpu_mask);
+ if (sched_setaffinity(0, size, cpu_mask) < 0) {
+ CPU_FREE(cpu_mask);
return errno;
+ }
+ CPU_FREE(cpu_mask);
return 0;
}
memset(&hdr, 0, sizeof(hdr));
hdr.magic = BLK_IO_TRACE_MAGIC;
+ memset(hdr.buts_name, 0, sizeof(hdr.buts_name));
strncpy(hdr.buts_name, buts_name, sizeof(hdr.buts_name));
- hdr.buts_name[sizeof(hdr.buts_name)-1] = '\0';
+ hdr.buts_name[sizeof(hdr.buts_name) - 1] = '\0';
hdr.cpu = cpu;
hdr.max_cpus = ncpus;
hdr.len = len;
}
memcpy(&addr->sin_addr, hent->h_addr, 4);
- strcpy(hostname, hent->h_name);
+ memset(hostname, 0, sizeof(hostname));
+ strncpy(hostname, hent->h_name, sizeof(hostname));
+ hostname[sizeof(hostname) - 1] = '\0';
}
return 0;
{
struct stat sb;
int i, nentries = 0;
- struct pdc_stats *sp;
struct pollfd *pfd = tp->pfds;
struct io_info *iop = tp->ios;
- for (i = 0; i < ndevs; i++, pfd++, iop++, sp++) {
+ for (i = 0; i < ndevs; i++, pfd++, iop++) {
if (pfd->revents & POLLIN || force_read) {
if (fstat(iop->ifd, &sb) < 0) {
perror(iop->ifn);
struct tracer *tp = list_entry(p, struct tracer, head);
tp->is_done = 1;
}
+ pthread_cond_broadcast(&mt_cond);
}
static void del_tracers(void)
return 1;
}
- while (fscanf(ifp, "%s\n", dev_line) == 1)
- if (add_devpath(dev_line) != 0)
+ while (fscanf(ifp, "%s\n", dev_line) == 1) {
+ if (add_devpath(dev_line) != 0) {
+ fclose(ifp);
return 1;
+ }
+ }
+ fclose(ifp);
break;
}
break;
case 'h':
net_mode = Net_client;
- strcpy(hostname, optarg);
+ memset(hostname, 0, sizeof(hostname));
+ strncpy(hostname, optarg, sizeof(hostname));
+ hostname[sizeof(hostname) - 1] = '\0';
break;
case 'l':
net_mode = Net_server;
piped_output = 1;
handle_pfds = handle_pfds_entries;
pfp = stdout;
- setvbuf(pfp, NULL, _IONBF, 0);
+ if (setvbuf(pfp, NULL, _IONBF, 0)) {
+ perror("setvbuf stdout");
+ return 1;
+ }
} else
handle_pfds = handle_pfds_file;
return 0;