Skip to content

Commit

Permalink
Minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
msantos committed Mar 13, 2012
1 parent 4928a68 commit 8afa967
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions c_src/serctl.c
Expand Up @@ -130,7 +130,7 @@ nif_read(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
if (!enif_alloc_binary(len, &buf))
return error_tuple(env, ENOMEM);

if ( (bufsz = read(sp->fd, buf.data, buf.size)) == -1) {
if ( (bufsz = read(sp->fd, buf.data, buf.size)) < 0) {
int err = errno;
enif_release_binary(&buf);
return error_tuple(env, err);
Expand All @@ -157,7 +157,7 @@ nif_write(ErlNifEnv *env, int argc, const ERL_NIF_TERM argv[])
if (!enif_inspect_binary(env, argv[1], &buf))
return enif_make_badarg(env);

if (write(sp->fd, buf.data, buf.size) == -1)
if (write(sp->fd, buf.data, buf.size) < 0)
return error_tuple(env, errno);

return atom_ok;
Expand Down
6 changes: 3 additions & 3 deletions c_src/serctl.h
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2011, Michael Santos <michael.santos@gmail.com>
* Copyright (c) 2011-2012, Michael Santos <michael.santos@gmail.com>
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
Expand Down Expand Up @@ -45,8 +45,8 @@
#define SRLY_VERSION "0.01"

struct SERCTL_DEF {
const char *key;
u_int32_t val;
const char *key;
u_int32_t val;
};

const struct SERCTL_DEF serctl_const[] = {
Expand Down

0 comments on commit 8afa967

Please sign in to comment.