Skip to content

Commit

Permalink
Fix linter warnings
Browse files Browse the repository at this point in the history
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti committed Nov 25, 2017
1 parent bb1e551 commit 6960474
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
5 changes: 2 additions & 3 deletions appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ install:
- cd C:\projects\winusb-driver-generator
- git submodule update --init --recursive
- ps: Install-Product node $env:nodejs_version $env:TARGET_ARCH
- npm install
- npm install --build-from-source
- pip install cpplint

build: off

test_script:
- npm run configure
- npm run build
- npm test
- node test.js
1 change: 1 addition & 0 deletions binding.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
],
"include_dirs" : [
"<!(node -e \"require('nan')\")",
'.'
],
"conditions": [
[ 'OS=="win"', {
Expand Down
23 changes: 15 additions & 8 deletions src/generator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,10 @@
* limitations under the License.
*/

#include "generator.h"
#include "src/generator.h"

static int generator_list_driverless_devices(struct wdi_device_info **result) {
static int
generator_list_driverless_devices(struct wdi_device_info **result) {
struct wdi_options_create_list options_list = { 0 };

// Only enumerate devices without a driver
Expand All @@ -37,10 +38,13 @@ NAN_METHOD(hasDriver) {
return Nan::ThrowError("Vendor id must be a number");
}

const unsigned short vendor = info[0]->Uint32Value();
const unsigned short product = info[1]->Uint32Value();
const uint16_t vendor = info[0]->Uint32Value();
const uint16_t product = info[1]->Uint32Value();

std::cout << "Searching for device: " << std::hex << "0x" << vendor << ":0x" << product << std::endl;
std::cout << "Searching for device: " << std::hex
<< "0x" << vendor
<< ":0x" << product
<< std::endl;
wdi_set_log_level(WDI_LOG_LEVEL_WARNING);

bool found = false;
Expand All @@ -49,7 +53,8 @@ NAN_METHOD(hasDriver) {

code = generator_list_driverless_devices(&device_list_node);
if (code == WDI_SUCCESS) {
for (; device_list_node != NULL; device_list_node = device_list_node->next) {
for (; device_list_node != NULL
; device_list_node = device_list_node->next) {
std::cout << "Found: " << std::hex
<< "0x" << device_list_node->vid
<< ":0x" << device_list_node->pid
Expand Down Expand Up @@ -78,13 +83,15 @@ NAN_METHOD(hasDriver) {
// can assume every device has a driver, including the
// one the user asked about.
} else if (code == WDI_ERROR_NO_DEVICE) {
std::cout << "No driverless device detected. Assuming device has a driver" << std::endl;
std::cout << "No driverless device detected. "
"Assuming device has a driver" << std::endl;
found = true;
} else {
if (code == WDI_ERROR_RESOURCE) {
Nan::ThrowError("Memory could not be allocated internally");
} else if (code == WDI_ERROR_BUSY) {
Nan::ThrowError("Another instance of this function call is already in process");
Nan::ThrowError("Another instance of this function call"
"is already in process");
} else {
Nan::ThrowError("Unknown error");
}
Expand Down
9 changes: 5 additions & 4 deletions src/generator.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@
* limitations under the License.
*/

#include <nan.h>
#include <iostream>
#include <stdio.h>
#include <nan.h>
#include <libwdi.h>
#include <iostream>

// Pragmas recommended by libwdi
#if defined(_PREFAST_)
// Disable "Banned API Usage:" errors when using WDK's OACR/Prefast */
// Disable "Banned API Usage:" errors when using WDK's OACR/Prefast
#pragma warning(disable:28719)
// Disable "Consider using 'GetTickCount64' instead of 'GetTickCount'" when using WDK's OACR/Prefast */
// Disable "Consider using 'GetTickCount64' instead of
// 'GetTickCount'" when using WDK's OACR/Prefast
#pragma warning(disable:28159)
#endif

Expand Down
6 changes: 4 additions & 2 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
* limitations under the License.
*/

const winusbDriverGenerator = require('.')
'use strict';

console.log(winusbDriverGenerator.hasDriver(0x0a5c, 0x2764))
const winusbDriverGenerator = require('.');

console.log(winusbDriverGenerator.hasDriver(0x0a5c, 0x2764));

0 comments on commit 6960474

Please sign in to comment.