Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix linter warnings #2

Merged
merged 1 commit into from
Nov 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));