summaryrefslogtreecommitdiff
path: root/btt/latency.c
diff options
context:
space:
mode:
authorAlan D. Brunelle <alan.brunelle@hp.com>2009-02-13 12:43:45 -0500
committerAlan D. Brunelle <alan.brunelle@hp.com>2009-02-13 12:43:45 -0500
commitc053af429559c8f4311cd773262ff223097cdcb3 (patch)
treee54213ccebb11d9dafce4d8376e4027983afb48d /btt/latency.c
parent8f34184f8c7905bb929862d224a7c4969bc9190e (diff)
downloadblktrace-c053af429559c8f4311cd773262ff223097cdcb3.tar.gz
blktrace-c053af429559c8f4311cd773262ff223097cdcb3.tar.bz2
btt general cleanup plus valgrind clean
Lots of general clean up of code, getting interfaces across different files to be similar (all are no alloc/free), and made it valgrind clean. Signed-off-by: Alan D. Brunelle <alan.brunelle@hp.com
Diffstat (limited to 'btt/latency.c')
-rw-r--r--btt/latency.c33
1 files changed, 13 insertions, 20 deletions
diff --git a/btt/latency.c b/btt/latency.c
index d12f60c..e3ecc26 100644
--- a/btt/latency.c
+++ b/btt/latency.c
@@ -20,8 +20,6 @@
*/
#include "globals.h"
-static struct file_info *all_files = NULL;
-
static inline void latency_out(FILE *ofp, __u64 tstamp, __u64 latency)
{
if (ofp)
@@ -30,37 +28,32 @@ static inline void latency_out(FILE *ofp, __u64 tstamp, __u64 latency)
FILE *latency_open(__u32 device, char *name, char *post)
{
- FILE *fp;
- char *oname;
- int mjr, mnr;
+ FILE *fp = NULL;
- if (name == NULL) return NULL;
+ if (name) {
+ int mjr, mnr;
+ char oname[strlen(name) + 32];
- mjr = device >> MINORBITS;
- mnr = device & ((1 << MINORBITS) - 1);
+ mjr = device >> MINORBITS;
+ mnr = device & ((1 << MINORBITS) - 1);
- oname = malloc(strlen(name)+32);
- sprintf(oname, "%s_%03d,%03d_%s.dat", name, mjr, mnr, post);
- if ((fp = my_fopen(oname, "w")) == NULL)
- perror(oname);
- else
- add_file(&all_files, fp, oname);
+ sprintf(oname, "%s_%03d,%03d_%s.dat", name, mjr, mnr, post);
+ if ((fp = my_fopen(oname, "w")) == NULL)
+ perror(oname);
+ else
+ add_file(fp, strdup(oname));
+ }
return fp;
}
-void latency_init(struct d_info *dip)
+void latency_alloc(struct d_info *dip)
{
dip->q2d_ofp = latency_open(dip->device, q2d_name, "q2d");
dip->d2c_ofp = latency_open(dip->device, d2c_name, "d2c");
dip->q2c_ofp = latency_open(dip->device, q2c_name, "q2c");
}
-void latency_clean(void)
-{
- clean_files(&all_files);
-}
-
void latency_q2d(struct d_info *dip, __u64 tstamp, __u64 latency)
{
plat_x2c(dip->q2d_plat_handle, tstamp, latency);