All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jens Axboe <jaxboe@fusionio.com>
To: linux-btrace@vger.kernel.org
Subject: Recent changes
Date: Thu, 02 Feb 2012 05:00:02 +0000	[thread overview]
Message-ID: <20120202050002.C7229484005@kernel.dk> (raw)
In-Reply-To: <46171742.iJ5w/0J1D3Q4P+M6%jens.axboe@oracle.com>

The following changes since commit 7f0062f7b893a80afbe0e43f5db157c7bc1a01f9:

  blktrace 1.0.4 (2012-01-31 10:53:21 +0100)

are available in the git repository at:
  git://git.kernel.dk/blktrace.git master

Eric Sandeen (10):
      Check setvbuf return value
      Fix potential array overrun in act_to_str
      Free pdu_buff on bad pdu path in process()
      Close stream in 'I' switch handling
      Remove extraneous malloc in find_input routines
      Fix several leaks on error paths
      btt: close devmap file after processing
      blkparse: initialize cpu_map
      blktrace: remove unused variable
      avoid string overflows

Jens Axboe (1):
      Fix compiler warnings

 blkparse.c          |    5 ++++-
 blkrawverify.c      |    3 ++-
 blktrace.c          |   27 +++++++++++++++++++--------
 btreplay/btrecord.c |    2 +-
 btreplay/btreplay.c |    2 +-
 btt/aqd.c           |    2 ++
 btt/bno_dump.c      |    5 +++--
 btt/devmap.c        |    1 +
 btt/plat.c          |    2 ++
 btt/proc.c          |    3 +--
 btt/seek.c          |   20 +++++++++-----------
 btt/trace_queue.c   |    2 +-
 12 files changed, 46 insertions(+), 28 deletions(-)

---

Diff of recent changes:

diff --git a/blkparse.c b/blkparse.c
index 0f8d135..b0b88c3 100644
--- a/blkparse.c
+++ b/blkparse.c
@@ -562,7 +562,9 @@ static struct process_pid_map *add_ppm_hash(pid_t pid, const char *name)
 		ppm = malloc(sizeof(*ppm));
 		memset(ppm, 0, sizeof(*ppm));
 		ppm->pid = pid;
-		strcpy(ppm->comm, name);
+		memset(ppm->comm, 0, sizeof(ppm->comm));
+		strncpy(ppm->comm, name, sizeof(ppm->comm));
+		ppm->comm[sizeof(ppm->comm) - 1] = '\0';
 		ppm->hash_next = ppm_hash_table[hash_idx];
 		ppm_hash_table[hash_idx] = ppm;
 	}
@@ -1962,6 +1964,7 @@ static int check_cpu_map(struct per_dev_info *pdi)
 	 * create a map of the cpus we have traces for
 	 */
 	cpu_map = malloc(pdi->cpu_map_max / sizeof(long));
+	memset(cpu_map, 0, sizeof(*cpu_map));
 	n = rb_first(&rb_sort_root);
 	while (n) {
 		__t = rb_entry(n, struct trace, rb_node);
diff --git a/blkrawverify.c b/blkrawverify.c
index b6ceb9d..ed5d258 100644
--- a/blkrawverify.c
+++ b/blkrawverify.c
@@ -87,7 +87,7 @@ static char *act_to_str(__u32 action)
 	unsigned int act = action & 0xffff;
 	unsigned int trace = (action >> BLK_TC_SHIFT) & 0xffff;
 
-	if (act <= N_ACTS) {
+	if (act < N_ACTS) {
 		sprintf(buf, "%s ", acts[act].string);
 		for (i = 0; i < N_TRACES; i++)
 			if (trace & (1 << i)) {
@@ -201,6 +201,7 @@ static int process(FILE **fp, char *devname, char *file, unsigned int cpu)
 			if (n = 0) {
 				INC_BAD("bad pdu");
 				nbad_seq++;
+				free(pdu_buf);
 				break;
 			}
 			free(pdu_buf);
diff --git a/blktrace.c b/blktrace.c
index b14daf2..89aaaac 100644
--- a/blktrace.c
+++ b/blktrace.c
@@ -872,8 +872,9 @@ static int net_send_header(int fd, int cpu, char *buts_name, int len)
 	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;
@@ -981,7 +982,9 @@ retry:
 		}
 
 		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;
@@ -1728,11 +1731,10 @@ static int handle_pfds_netclient(struct tracer *tp, int nevs, int force_read)
 {
 	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);
@@ -2076,9 +2078,13 @@ static int handle_args(int argc, char *argv[])
 				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;
 		}
 
@@ -2128,7 +2134,9 @@ static int handle_args(int argc, char *argv[])
 			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;
@@ -2183,7 +2191,10 @@ static int handle_args(int argc, char *argv[])
 		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;
diff --git a/btreplay/btrecord.c b/btreplay/btrecord.c
index 88ab806..3646257 100644
--- a/btreplay/btrecord.c
+++ b/btreplay/btrecord.c
@@ -365,7 +365,7 @@ static void find_input_files(char *idir)
 	}
 
 	while ((ent = readdir(dir)) != NULL) {
-		char *p, *dsf = malloc(256);
+		char *p, *dsf;
 
 		if (strstr(ent->d_name, ".blktrace.") = NULL)
 			continue;
diff --git a/btreplay/btreplay.c b/btreplay/btreplay.c
index f4f5aa0..20494e0 100644
--- a/btreplay/btreplay.c
+++ b/btreplay/btreplay.c
@@ -596,7 +596,7 @@ static void find_input_devs(char *idir)
 	}
 
 	while ((ent = readdir(dir)) != NULL) {
-		char *p, *dsf = malloc(256);
+		char *p, *dsf;
 
 		if (strstr(ent->d_name, ".replay.") = NULL)
 			continue;
diff --git a/btt/aqd.c b/btt/aqd.c
index 3bb6f85..17ab15b 100644
--- a/btt/aqd.c
+++ b/btt/aqd.c
@@ -43,6 +43,8 @@ void *aqd_alloc(struct d_info *dip)
 	sprintf(oname, "%s_%s_aqd.dat", aqd_name, dip->dip_name);
 	if ((ap->fp = my_fopen(oname, "w")) = NULL) {
 		perror(oname);
+		free(oname);
+		free(ap);
 		return NULL;
 	}
 	add_file(ap->fp, oname);
diff --git a/btt/bno_dump.c b/btt/bno_dump.c
index 02f3811..00c9ac2 100644
--- a/btt/bno_dump.c
+++ b/btt/bno_dump.c
@@ -31,9 +31,10 @@ static FILE *bno_dump_open(struct d_info *dip, char rwc)
 
 	oname = malloc(strlen(bno_dump_name) + strlen(dip->dip_name) + 32);
 	sprintf(oname, "%s_%s_%c.dat", bno_dump_name, dip->dip_name, rwc);
-	if ((fp = my_fopen(oname, "w")) = NULL)
+	if ((fp = my_fopen(oname, "w")) = NULL) {
 		perror(oname);
-	else
+		free(oname);
+	} else
 		add_file(fp, oname);
 	return fp;
 }
diff --git a/btt/devmap.c b/btt/devmap.c
index 9c0348b..0553a9e 100644
--- a/btt/devmap.c
+++ b/btt/devmap.c
@@ -76,6 +76,7 @@ int dev_map_read(char *fname)
 			break;
 	}
 
+	fclose(fp);
 	return 0;
 }
 
diff --git a/btt/plat.c b/btt/plat.c
index e7b7dde..dff7115 100644
--- a/btt/plat.c
+++ b/btt/plat.c
@@ -42,6 +42,8 @@ void *plat_alloc(struct d_info *dip, char *post)
 	sprintf(oname, "%s%s_plat.dat", dip->dip_name, post);
 	if ((pp->fp = my_fopen(oname, "w")) = NULL) {
 		perror(oname);
+		free(oname);
+		free(pp);
 		return NULL;
 	}
 	add_file(pp->fp, oname);
diff --git a/btt/proc.c b/btt/proc.c
index aac49cb..eb44c3d 100644
--- a/btt/proc.c
+++ b/btt/proc.c
@@ -238,9 +238,8 @@ void pip_foreach_out(void (*f)(struct p_info *, void *), void *arg)
 		__foreach(root_name.rb_node, f, arg);
 	else {
 		struct p_info *pip;
-		char *exe, *p, *next, *exes_save = strdup(exes);
+		char *exe, *next, *exes_save = strdup(exes);
 
-		p = exes_save;
 		while (exes_save != NULL) {
 			exe = exes_save;
 			if ((next = strchr(exes_save, ',')) != NULL) {
diff --git a/btt/seek.c b/btt/seek.c
index abdb0ee..52f6a21 100644
--- a/btt/seek.c
+++ b/btt/seek.c
@@ -51,9 +51,10 @@ static FILE *seek_open(char *str, char rw)
 
 	oname = malloc(strlen(seek_name) + strlen(str) + 32);
 	sprintf(oname, "%s_%s_%c.dat", seek_name, str, rw);
-	if ((fp = my_fopen(oname, "w")) = NULL)
+	if ((fp = my_fopen(oname, "w")) = NULL) {
 		perror(oname);
-	else
+		free(oname);
+	} else
 		add_file(fp, oname);
 
 	return fp;
@@ -99,18 +100,14 @@ static void __destroy(struct rb_node *n)
 
 static void sps_emit(struct seeki *sip)
 {
-	double tstamp, s_p_s;
+	double s_p_s;
 	struct sps_bkt *sps = &sip->sps;
 	double delta = sps->t_last - sps->t_start;
 
-	if ((sps->nseeks = 1) || (delta < DBL_EPSILON)) {
+	if ((sps->nseeks = 1) || (delta < DBL_EPSILON))
 		s_p_s = (double)(sps->nseeks);
-		tstamp = sps->t_start;
-	} else {
-
+	else
 		s_p_s = (double)(sps->nseeks) / delta;
-		tstamp = sps->t_start + (delta / 2);
-	}
 
 	fprintf(sip->sps_fp, "%15.9lf %.2lf\n", sps->t_start, s_p_s);
 
@@ -226,9 +223,10 @@ void *seeki_alloc(struct d_info *dip, char *post)
 
 		oname = malloc(strlen(sps_name) + strlen(dip->dip_name) + 32);
 		sprintf(oname, "%s_%s.dat", sps_name, dip->dip_name);
-		if ((sip->sps_fp = my_fopen(oname, "w")) = NULL)
+		if ((sip->sps_fp = my_fopen(oname, "w")) = NULL) {
 			perror(oname);
-		else
+			free(oname);
+		} else
 			add_file(sip->sps_fp, oname);
 	} else
 		sip->sps_fp = NULL;
diff --git a/btt/trace_queue.c b/btt/trace_queue.c
index 82c5760..8edcd90 100644
--- a/btt/trace_queue.c
+++ b/btt/trace_queue.c
@@ -33,7 +33,7 @@ static void handle_queue(struct io *q_iop)
 		update_lq(&last_q, &all_avgs.q2q, q_iop->t.time);
 	}
 
-	q_iop->i_time = q_iop->g_time = q_iop->i_time = q_iop->m_time +	q_iop->i_time = q_iop->g_time = q_iop->c_time = q_iop->m_time  						q_iop->d_time = (__u64)-1;
 	q_iop->dip->n_qs++;
 

  parent reply	other threads:[~2012-02-02  5:00 UTC|newest]

Thread overview: 135+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-04-07  3:56 Recent changes Jens Axboe
2007-04-14  4:00 ` Jens Axboe
2007-04-15  4:00 ` Jens Axboe
2007-04-17  4:00 ` Jens Axboe
2007-04-19  4:00 ` Jens Axboe
2007-05-12  4:00 ` Jens Axboe
2007-05-17  4:00 ` Jens Axboe
2007-05-22  4:00 ` Jens Axboe
2007-05-31  4:00 ` Jens Axboe
2007-06-01  4:00 ` Jens Axboe
2007-06-14  4:00 ` Jens Axboe
2007-07-19  4:00 ` Jens Axboe
2007-07-25  4:00 ` Jens Axboe
2007-07-31  4:00 ` Jens Axboe
2007-08-21  4:00 ` Jens Axboe
2007-08-27  4:00 ` Jens Axboe
2007-08-28  4:00 ` Jens Axboe
2007-08-29  4:00 ` Jens Axboe
2007-09-11  4:00 ` Jens Axboe
2007-10-02  4:00 ` Jens Axboe
2007-10-03  4:00 ` Jens Axboe
2007-10-06  4:00 ` Jens Axboe
2007-10-11  4:00 ` Jens Axboe
2007-10-30  5:00 ` Jens Axboe
2007-11-09  5:00 ` Jens Axboe
2007-11-14  5:00 ` Jens Axboe
2007-11-15  5:00 ` Jens Axboe
2007-12-07  5:00 ` Jens Axboe
2007-12-08  5:00 ` Jens Axboe
2007-12-10  5:00 ` Jens Axboe
2007-12-11  5:00 ` Jens Axboe
2008-01-04  5:00 ` Jens Axboe
2008-02-01  5:00 ` Jens Axboe
2008-02-06  5:00 ` Jens Axboe
2008-02-09  5:00 ` Jens Axboe
2008-02-13  5:00 ` Jens Axboe
2008-02-14  5:00 ` Jens Axboe
2008-02-23  5:00 ` Jens Axboe
2008-04-03  4:00 ` Jens Axboe
2008-04-03  7:04 ` Jens Axboe
2008-05-06  4:00 ` Jens Axboe
2008-05-09  4:00 ` Jens Axboe
2008-05-10  4:00 ` Jens Axboe
2008-05-13  4:00 ` Jens Axboe
2008-05-19  4:00 ` Jens Axboe
2008-05-22  4:00 ` Jens Axboe
2008-05-28  4:00 ` Jens Axboe
2008-07-02  4:00 ` Jens Axboe
2008-08-16  4:00 ` Jens Axboe
2008-09-27  4:00 ` Jens Axboe
2008-10-11  4:00 ` Jens Axboe
2008-10-17  4:00 ` Jens Axboe
2008-10-18  4:00 ` Jens Axboe
2008-10-21  4:00 ` Jens Axboe
2008-10-29  5:00 ` Jens Axboe
2008-10-31  5:00 ` Jens Axboe
2008-11-11  5:00 ` Jens Axboe
2008-11-12  5:00 ` Jens Axboe
2008-11-13  5:00 ` Jens Axboe
2009-01-13  5:00 ` Jens Axboe
2009-01-22  5:00 ` Jens Axboe
2009-01-24  5:00 ` Jens Axboe
2009-02-10  5:00 ` Jens Axboe
2009-02-12  5:00 ` Jens Axboe
2009-02-13  5:00 ` Jens Axboe
2009-02-14  5:00 ` Jens Axboe
2009-02-18  5:00 ` Jens Axboe
2009-02-19  5:00 ` Jens Axboe
2009-03-13  5:00 ` Jens Axboe
2009-03-24  5:00 ` Jens Axboe
2009-03-26  5:00 ` Jens Axboe
2009-03-27  5:00 ` Jens Axboe
2009-04-07  4:00 ` Jens Axboe
2009-04-18  4:00 ` Jens Axboe
2009-04-22  4:00 ` Jens Axboe
2009-05-13  4:00 ` Jens Axboe
2009-08-15  4:00 ` Jens Axboe
2009-09-02  4:00 ` Jens Axboe
2009-10-09  4:00 ` Jens Axboe
2009-10-10  4:00 ` Jens Axboe
2010-02-23  5:00 ` Jens Axboe
2010-03-23  5:00 ` Jens Axboe
2010-04-20  4:00 ` Jens Axboe
2010-04-21  4:00 ` Jens Axboe
2010-09-17  4:00 ` Jens Axboe
2010-10-12 15:38 ` Edward Shishkin
2010-10-12 16:52 ` Jens Axboe
2010-10-23  4:00 ` Jens Axboe
2010-12-02  5:00 ` Jens Axboe
2010-12-20  4:36 ` Duy Le (Dan)
2011-01-12  5:00 ` Jens Axboe
2011-01-15  5:00 ` Jens Axboe
2011-02-10  5:00 ` Jens Axboe
2011-03-17  5:00 ` Jens Axboe
2011-05-27  4:00 ` Jens Axboe
2011-08-04  4:00 ` Jens Axboe
2011-08-04 11:50 ` Edward Shishkin
2011-08-04 12:08 ` Jens Axboe
2011-08-12  4:00 ` Jens Axboe
2012-02-01  5:00 ` Jens Axboe
2012-02-02  5:00 ` Jens Axboe [this message]
2012-02-28  5:00 ` Jens Axboe
     [not found] <20090409040002.0D18237A271@kernel.dk>
2009-04-17 21:38 ` Girish Satihal
2009-04-18 17:48   ` Jens Axboe
2009-04-20 14:42     ` Girish Satihal
2009-04-20 18:05       ` Jens Axboe
2009-04-20 20:54         ` Girish Satihal
2009-04-21  5:28           ` Jens Axboe
2009-04-21  7:47             ` Jens Axboe
2009-04-21 15:46               ` Girish Satihal
2009-04-21 19:15                 ` Jens Axboe
2009-04-21 22:17                   ` Girish Satihal
2009-04-22  5:46                     ` Jens Axboe
2009-04-22  5:53                       ` Gurudas Pai
2009-04-22 16:46                       ` Girish Satihal
2009-04-22 17:40                         ` Jens Axboe
     [not found] <869776.96350.qm@web63807.mail.re1.yahoo.com>
2009-04-24  4:40 ` Gurudas Pai
  -- strict thread matches above, loose matches on Subject: below --
2010-11-06  5:00 Jens Axboe
     [not found] <20110114050004.0ECBF37A2F4@kernel.dk>
2011-01-14 11:38 ` Bruce Cran
2011-01-14 11:41   ` Jens Axboe
     [not found] <20110127050004.1AE9737A304@kernel.dk>
2011-01-27  8:51 ` Bruce Cran
2011-01-27  9:08   ` Jens Axboe
     [not found] <20110125050003.F378B37A302@kernel.dk>
2011-01-27 21:08 ` Steven Pratt
2011-01-27 21:12   ` Jens Axboe
2011-01-27 22:06   ` Bruce Cran
2011-01-28  8:28     ` Jens Axboe
2011-06-28  9:36 Konstantin Belousov
2011-06-28 10:37 ` Chris Wilson
2011-10-14  4:00 Jens Axboe
     [not found] <20120406040004.1BF99484001@kernel.dk>
2012-04-06  4:29 ` Danny Kukawka
2012-04-06 13:31   ` Jens Axboe
2012-04-06 17:40     ` Danny Kukawka
2012-04-06 17:44       ` Jens Axboe
2012-04-14  6:45         ` Danny Kukawka
2012-04-14 14:47           ` Jens Axboe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120202050002.C7229484005@kernel.dk \
    --to=jaxboe@fusionio.com \
    --cc=linux-btrace@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.