[rygel/wip/basic-management: 49/49] core: Fix BasicManagement style issues
- From: Jussi Kukkonen <jussik src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [rygel/wip/basic-management: 49/49] core: Fix BasicManagement style issues
- Date: Wed, 23 Oct 2013 13:17:05 +0000 (UTC)
commit d50bf506b902f86e34ffad9009a0d20aff9f96ae
Author: Jussi Kukkonen <jussi kukkonen intel com>
Date: Wed Oct 23 15:13:05 2013 +0300
core: Fix BasicManagement style issues
.../rygel-basic-management-test-nslookup.vala | 18 +++++++-----
.../rygel-basic-management-test-traceroute.vala | 14 +++++----
src/librygel-core/rygel-basic-management-test.vala | 29 ++++++++++++-------
3 files changed, 37 insertions(+), 24 deletions(-)
---
diff --git a/src/librygel-core/rygel-basic-management-test-nslookup.vala
b/src/librygel-core/rygel-basic-management-test-nslookup.vala
index 1ff6689..c74ac83 100644
--- a/src/librygel-core/rygel-basic-management-test-nslookup.vala
+++ b/src/librygel-core/rygel-basic-management-test-nslookup.vala
@@ -125,8 +125,9 @@ internal class Rygel.BasicManagementTestNSLookup : BasicManagementTest {
private string get_addresses_csv () {
var builder = new StringBuilder ("");
foreach (var address in this.addresses) {
- if (builder.len != 0)
+ if (builder.len != 0) {
builder.append (",");
+ }
builder.append (address);
}
@@ -169,8 +170,9 @@ internal class Rygel.BasicManagementTestNSLookup : BasicManagementTest {
public uint repetitions {
construct {
this.iterations = value;
- if (this.iterations == 0)
+ if (this.iterations == 0) {
this.iterations = DEFAULT_REPETITIONS;
+ }
}
private get {
@@ -297,12 +299,12 @@ internal class Rygel.BasicManagementTestNSLookup : BasicManagementTest {
line.strip ();
if (line.has_prefix ("Server:")) {
if (result.state != ProcessState.INIT) {
- warning ("nslookup parser: Unexpected 'Server:' line.\n");
+ debug ("nslookup parser: Unexpected 'Server:' line.\n");
}
result.state = ProcessState.SERVER;
} else if (line.has_prefix ("Name:")) {
if (result.state == ProcessState.INIT) {
- warning ("nslookup parser: Unexpected 'Name:' line");
+ debug ("nslookup parser: Unexpected 'Name:' line");
} else if (result.state == ProcessState.SERVER) {
var name = line.substring ("Name:".length).strip ();
result.returned_host_name = name;
@@ -316,10 +318,11 @@ internal class Rygel.BasicManagementTestNSLookup : BasicManagementTest {
} else if (result.state == ProcessState.NAME) {
result.addresses += line.substring ("Address:".length).strip ();
result.status = ResultStatus.SUCCESS;
- if (result.answer_type == AnswerType.NONE)
+ if (result.answer_type == AnswerType.NONE) {
result.answer_type = AnswerType.AUTHORITATIVE;
+ }
} else {
- warning ("nslookup parser: Unexpected 'Address:' line");
+ debug ("nslookup parser: Unexpected 'Address:' line");
}
} else if (line.has_prefix ("Non-authoritative answer:")) {
result.answer_type = AnswerType.NON_AUTHORITATIVE;
@@ -344,8 +347,9 @@ internal class Rygel.BasicManagementTestNSLookup : BasicManagementTest {
foreach (var result in this.results) {
builder.append (result.to_xml_fragment ());
- if (result.status == ResultStatus.SUCCESS)
+ if (result.status == ResultStatus.SUCCESS) {
success_count++;
+ }
}
builder.append (FOOTER);
result_string = builder.str;
diff --git a/src/librygel-core/rygel-basic-management-test-traceroute.vala
b/src/librygel-core/rygel-basic-management-test-traceroute.vala
index 6dd1227..3147f17 100644
--- a/src/librygel-core/rygel-basic-management-test-traceroute.vala
+++ b/src/librygel-core/rygel-basic-management-test-traceroute.vala
@@ -175,7 +175,7 @@ internal class Rygel.BasicManagementTestTraceroute : BasicManagementTest {
this.regex = new Regex ("^\\s*(\\d+)\\s+(\\S+)\\s*(.*)$", 0, 0);
this.rtt_regex = new Regex ("(\\S+)\\s+ms\\b", 0, 0);
} catch (Error e) {
- warning ("Failed to create Regexes '%s'", e.message);
+ assert_not_reached ();
}
this.state = ProcessState.INIT;
@@ -252,7 +252,7 @@ internal class Rygel.BasicManagementTestTraceroute : BasicManagementTest {
this.host_ip = line.slice (start + 1, end);
}
} else {
- warning ("traceroute parser: Unexpected line '%s'", line);
+ debug ("traceroute parser: Unexpected line '%s'", line);
}
break;
case ProcessState.HOPS:
@@ -276,8 +276,8 @@ internal class Rygel.BasicManagementTestTraceroute : BasicManagementTest {
return;
}
MatchInfo info;
- if (!regex.match (line, 0, out info)) {
- warning ("traceroute parser: Unexpected line '%s'", line);
+ if (!this.regex.match (line, 0, out info)) {
+ debug ("traceroute parser: Unexpected line '%s'", line);
return;
}
@@ -298,7 +298,7 @@ internal class Rygel.BasicManagementTestTraceroute : BasicManagementTest {
}
var rtt_string = info.fetch (3);
- rtt_regex.match (rtt_string, 0, out info);
+ this.rtt_regex.match (rtt_string, 0, out info);
var rtt_count = 0;
var rtt_average = 0.0;
try {
@@ -308,7 +308,9 @@ internal class Rygel.BasicManagementTestTraceroute : BasicManagementTest {
info.next ();
}
} catch (RegexError e) {
- warning ("Regex error while parsing rtt values: %s", e.message);
+ debug ("Failed to parse round trip time values '%s': %s",
+ rtt_string,
+ e.message);
}
if (rtt_count > 0) {
diff --git a/src/librygel-core/rygel-basic-management-test.vala
b/src/librygel-core/rygel-basic-management-test.vala
index c0f6bcd..17aea78 100644
--- a/src/librygel-core/rygel-basic-management-test.vala
+++ b/src/librygel-core/rygel-basic-management-test.vala
@@ -103,7 +103,7 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
protected virtual void init_iteration () {}
protected virtual void handle_output (string line) {}
protected virtual void handle_error (string line) {
- warning ("%s stderr: %s", command[0], line);
+ debug ("%s stderr: %s", command[0], line);
}
protected virtual bool finish_iteration () {
this.current_iteration++;
@@ -131,7 +131,7 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
private void child_setup () {
/* try to prevent possible changes in output */
- Environment.set_variable("LC_MESSAGES", "C", true);
+ Environment.set_variable ("LC_MESSAGES", "C", true);
/* Create new session to detach from tty, but set a process
* group so all children can be ḱilled if need be */
@@ -144,7 +144,7 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
/*if we failed to initialize, skip spawning */
if (this.init_state != InitState.OK) {
- Idle.add ((SourceFunc)this.finish_iteration);
+ Idle.add (this.finish_iteration);
return;
}
@@ -173,7 +173,7 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
/* Let the async function yeild, then let the Test
* implementation handle this in finish_iteration */
this.init_state = InitState.SPAWN_FAILED;
- Idle.add ((SourceFunc)this.finish_iteration);
+ Idle.add (this.finish_iteration);
}
}
@@ -187,14 +187,17 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
if (status == IOStatus.EOF) {
this.eof_count++;
- if (this.eof_count > 1)
+ if (this.eof_count > 1) {
this.finish_iteration ();
+ }
return false;
}
} catch (Error e) {
- warning ("Failed readline() from stdout: %s", e.message);
- this.finish_iteration();
+ warning (_("Failed to read standard output from %s: %s"),
+ this.method_type,
+ e.message);
+ this.finish_iteration ();
return false;
}
@@ -219,8 +222,10 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
return false;
}
} catch (Error e) {
- warning ("Failed readline() from stderr: %s", e.message);
- this.finish_iteration();
+ warning (_("Failed to read error output from %s: %s"),
+ this.method_type,
+ e.message);
+ this.finish_iteration ();
return false;
}
@@ -235,11 +240,13 @@ internal abstract class Rygel.BasicManagementTest : Object, StateMachine {
public async virtual void run () {
if (this.execution_state != ExecutionState.REQUESTED) {
- warning ("Test already started");
+ debug ("Not running test: already started");
+
return;
}
- if (this.cancellable == null)
+ if (this.cancellable == null) {
this.cancellable = new Cancellable ();
+ }
this.execution_state = ExecutionState.IN_PROGRESS;
this.current_iteration = 0;
this.async_callback = run.callback;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]