From: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
To: linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Cc: "Smith, Stan" <stan.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Subject: [PATCH] opensm/osm_db_files.c: add '/' path delimited
Date: Sat, 28 Nov 2009 16:26:26 +0200 [thread overview]
Message-ID: <20091128142626.GB16607@me> (raw)
In-Reply-To: <20091128142342.GA16607@me>
Add '/' path delimiter unconditionally on file path generation.
Signed-off-by: Sasha Khapyorsky <sashak-smomgflXvOZWk0Htik3J/w@public.gmane.org>
---
opensm/opensm/osm_db_files.c | 14 ++++++--------
1 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/opensm/opensm/osm_db_files.c b/opensm/opensm/osm_db_files.c
index ec7436e..5fd7c83 100644
--- a/opensm/opensm/osm_db_files.c
+++ b/opensm/opensm/osm_db_files.c
@@ -195,7 +195,7 @@ osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN char *domain_name)
{
osm_db_domain_t *p_domain;
osm_db_domain_imp_t *p_domain_imp;
- int dir_name_len;
+ size_t path_len;
osm_log_t *p_log = p_db->p_log;
FILE *p_file;
@@ -209,16 +209,14 @@ osm_db_domain_t *osm_db_domain_init(IN osm_db_t * p_db, IN char *domain_name)
(osm_db_domain_imp_t *) malloc(sizeof(osm_db_domain_imp_t));
CL_ASSERT(p_domain_imp != NULL);
- dir_name_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name);
+ path_len = strlen(((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name)
+ + strlen(domain_name) + 2;
/* set the domain file name */
- p_domain_imp->file_name =
- (char *)malloc(sizeof(char) * (dir_name_len) + strlen(domain_name) +
- 2);
+ p_domain_imp->file_name = malloc(path_len);
CL_ASSERT(p_domain_imp->file_name != NULL);
- strcpy(p_domain_imp->file_name,
- ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name);
- strcat(p_domain_imp->file_name, domain_name);
+ snprintf(p_domain_imp->file_name, path_len, "%s/%s",
+ ((osm_db_imp_t *) p_db->p_db_imp)->db_dir_name, domain_name);
/* make sure the file exists - or exit if not writable */
p_file = fopen(p_domain_imp->file_name, "a+");
--
1.6.5.3
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
next prev parent reply other threads:[~2009-11-28 14:26 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-10-07 23:46 [PATCH] remove unnecessary leading '/' from filename Stan C. Smith
2009-10-12 21:54 ` Sasha Khapyorsky
2009-10-12 22:18 ` Smith, Stan
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912C896BBDA-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-11-28 14:23 ` Sasha Khapyorsky
2009-11-28 14:26 ` Sasha Khapyorsky [this message]
2009-11-28 14:27 ` [PATCH] opensm/osm_base.h: remove trailing '/' in OSM_DEFAULT_CACHE_DIR Sasha Khapyorsky
2009-11-28 16:35 ` [PATCH] opensm/osm_db_files.c: add '/' path delimited Smith, Stan
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912CC7DAF13-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-11-28 17:36 ` Bart Van Assche
[not found] ` <e2e108260911280936w27de9761r7a8818184f184535-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2009-11-28 20:16 ` Smith, Stan
2009-11-28 16:30 ` [PATCH] remove unnecessary leading '/' from filename Smith, Stan
[not found] ` <3F6F638B8D880340AB536D29CD4C1E1912CC7DAF12-osO9UTpF0USkrb+BlOpmy7fspsVTdybXVpNB7YpNyf8@public.gmane.org>
2009-11-29 12:49 ` Sasha Khapyorsky
[not found] ` <784A3771E5D143179461A7D5151AE78C-Zpru7NauK7drdx17CPfAsdBPR1lH4CV8@public.gmane.org>
2009-11-28 14:28 ` Sasha Khapyorsky
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=20091128142626.GB16607@me \
--to=sashak-smomgflxvozwk0htik3j/w@public.gmane.org \
--cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=stan.smith-ral2JQCrhuEAvxtiuMwx3w@public.gmane.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.