Permalink
Browse files

Fix warning: control reaches end of non-void function.

Add a test case - the missing return breaks net.getsockfamily()
but only in debug builds.
  • Loading branch information...
1 parent 95b409c commit 224bb54d281b65435db7f0ffceb33ab43727fed4 @bnoordhuis committed Jun 17, 2011
Showing with 28 additions and 1 deletion.
  1. +1 −1 src/node_net.cc
  2. +27 −0 test/simple/test-net-getsockfamily.js
View
@@ -625,7 +625,7 @@ static Handle<Value> GetSockFamily(const Arguments& args) {
default:
result = Integer::New((address_storage).ss_family);
}
- scope.Close(result);
+ return scope.Close(result);
}
static Handle<Value> GetPeerName(const Arguments& args) {
@@ -0,0 +1,27 @@
+// Copyright Joyent, Inc. and other Node contributors.
+//
+// Permission is hereby granted, free of charge, to any person obtaining a
+// copy of this software and associated documentation files (the
+// "Software"), to deal in the Software without restriction, including
+// without limitation the rights to use, copy, modify, merge, publish,
+// distribute, sublicense, and/or sell copies of the Software, and to permit
+// persons to whom the Software is furnished to do so, subject to the
+// following conditions:
+//
+// The above copyright notice and this permission notice shall be included
+// in all copies or substantial portions of the Software.
+//
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
+// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN
+// NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
+// DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
+// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
+// USE OR OTHER DEALINGS IN THE SOFTWARE.
+
+var assert = require('assert');
+var socket = process.binding('net').socket;
+var getsockfamily = process.binding('net').getsockfamily;
+
+assert.equal(getsockfamily(socket('unix')), 'AF_UNIX');
+assert.equal(getsockfamily(socket('tcp4')), 'AF_INET');

0 comments on commit 224bb54

Please sign in to comment.