From: Pete Zaitcev <zaitcev@redhat.com>
To: Jeff Garzik <jeff@garzik.org>
Cc: Project Hail List <hail-devel@vger.kernel.org>
Subject: [Patch 7/7] tabled: cleanup config.c re. empty elements
Date: Thu, 14 Jan 2010 21:14:18 -0700 [thread overview]
Message-ID: <20100114211418.43bacbdc@redhat.com> (raw)
I was changing it one by one, but honestly it was just stupid.
Let us change over to the sane checking once and for all.
Signed-Off-By: Pete Zaitcev <zaitcev@redhat.com>
---
server/config.c | 41 +++++++++++++++++++++++++++++++++--------
1 file changed, 33 insertions(+), 8 deletions(-)
commit 1d6ca69e3f5f2cae0d5630e785f69549d93080e5
Author: Master <zaitcev@lembas.zaitcev.lan>
Date: Thu Jan 14 20:04:27 2010 -0700
Switch cc->text checking completely to more precise variety.
diff --git a/server/config.c b/server/config.c
index 6fc7a88..301be66 100644
--- a/server/config.c
+++ b/server/config.c
@@ -158,7 +158,11 @@ static void cfg_elm_end (GMarkupParseContext *context,
struct stat statb;
long n;
- if (!strcmp(element_name, "PID") && cc->text) {
+ if (!strcmp(element_name, "PID")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "PID element empty");
+ return;
+ }
if (tabled_srv.pid_file) {
/* Silent about command line override. */
free(cc->text);
@@ -168,13 +172,22 @@ static void cfg_elm_end (GMarkupParseContext *context,
cc->text = NULL;
}
- else if (!strcmp(element_name, "ForceHost") && cc->text) {
+ else if (!strcmp(element_name, "ForceHost")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "ForceHost element empty");
+ return;
+ }
free(tabled_srv.ourhost);
tabled_srv.ourhost = cc->text;
cc->text = NULL;
}
- else if (!strcmp(element_name, "TDB") && cc->text) {
+ else if (!strcmp(element_name, "TDB")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "TDB element empty");
+ return;
+ }
+
if (stat(cc->text, &statb) < 0) {
applog(LOG_ERR, "stat(2) on TDB '%s' failed: %s",
cc->text, strerror(errno));
@@ -192,7 +205,12 @@ static void cfg_elm_end (GMarkupParseContext *context,
cc->text = NULL;
}
- else if (!strcmp(element_name, "TDBRepPort") && cc->text) {
+ else if (!strcmp(element_name, "TDBRepPort")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "TDBRepPort element empty");
+ return;
+ }
+
n = strtol(cc->text, NULL, 10);
if (n <= 0 || n >= 65536) {
applog(LOG_WARNING,
@@ -244,8 +262,7 @@ static void cfg_elm_end (GMarkupParseContext *context,
if (cc->in_listen) {
n = strtol(cc->text, NULL, 10);
- if ((n > 0 && n < 65536) ||
- !strcmp(cc->text, "auto")) {
+ if ((n > 0 && n < 65536) || !strcmp(cc->text, "auto")) {
free(cc->tmp_listen.port);
cc->tmp_listen.port = cc->text;
} else {
@@ -306,13 +323,21 @@ static void cfg_elm_end (GMarkupParseContext *context,
cc->text = NULL;
}
- else if (!strcmp(element_name, "ChunkUser") && cc->text) {
+ else if (!strcmp(element_name, "ChunkUser")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "ChunkUser element empty");
+ return;
+ }
free(tabled_srv.chunk_user);
tabled_srv.chunk_user = cc->text;
cc->text = NULL;
}
- else if (!strcmp(element_name, "ChunkKey") && cc->text) {
+ else if (!strcmp(element_name, "ChunkKey")) {
+ if (!cc->text) {
+ applog(LOG_WARNING, "ChunkKey element empty");
+ return;
+ }
free(tabled_srv.chunk_key);
tabled_srv.chunk_key = cc->text;
cc->text = NULL;
reply other threads:[~2010-01-15 4:14 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=20100114211418.43bacbdc@redhat.com \
--to=zaitcev@redhat.com \
--cc=hail-devel@vger.kernel.org \
--cc=jeff@garzik.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.