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 compiler warnings #4

Closed
andybrown668 opened this issue Mar 10, 2017 · 2 comments
Closed

fix compiler warnings #4

andybrown668 opened this issue Mar 10, 2017 · 2 comments

Comments

@andybrown668
Copy link

Hi, thanks for the lib - works great!
here's a patch to get rid of compiler warnings - I see these when cross-compiling to arm with
CC=arm-linux-gnueabi-gcc CGO_ENABLED=1 GOOS=linux GOARCH=arm GOARM=6 go build <app.go>

----------------------------------- dht.go.h -----------------------------------
index 6cda1e0..fc05c70 100644
@@ -7,6 +7,7 @@
#include <fcntl.h>
#include <sched.h>
#include <time.h>
+#include <unistd.h>

// GPIO direction: receive either output data to specific GPIO pin.
#define IN 0
@@ -52,7 +53,9 @@ static int gpio_export(int port, Pin *pin) {
}
(*pin).pin = port;
bytes_written = snprintf(buffer, BUFFER_MAX, "%d", (*pin).pin);

  • write(fd, buffer, bytes_written);
  • if (-1 == write(fd, buffer, bytes_written)){

  •    fprintf(stderr, "Failed to export pin!\n");
    
  • }
    close(fd);

    #define DIRECTION_MAX 35
    @@ -92,7 +95,9 @@ static int gpio_unexport(Pin *pin) {
    }

    bytes_written = snprintf(buffer, BUFFER_MAX, "%d", (*pin).pin);

  • write(fd, buffer, bytes_written);
  • if (-1 == write(fd, buffer, bytes_written)){
  •    fprintf(stderr, "Failed to unexport pin!\n");
    
  • }
    close(fd);
    return 0;
    }
@d2r2
Copy link
Owner

d2r2 commented Mar 28, 2017

Hi, @andybrown668! Thank you for pleasant words regarding this lib :)
Give me few days and I will come back with extended answer.
Frankly, I never try to cross comply this lib (and made all this stuff few years ago), so give me some time to reproduce this issue, with the approach you describe.

@d2r2
Copy link
Owner

d2r2 commented Jul 30, 2017

@andybrown668, thanks again for pointing issue in C-code! Your changes proposed merged to the library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants