summaryrefslogtreecommitdiffstats
path: root/gatchat
diff options
context:
space:
mode:
authorLucas De Marchi <lucas.demarchi@profusion.mobi>2010-11-27 17:39:00 -0200
committerDenis Kenzior <denkenz@gmail.com>2010-11-29 12:05:29 -0600
commit521071a7853b225713606de3e0421e680f187709 (patch)
tree57927fea85638f448436ea02706b99429ff13fc5 /gatchat
parent00cdf2b427a788492baeb0e29b9063a36ef1effe (diff)
downloadofono-521071a7853b225713606de3e0421e680f187709.tar.bz2
gatchat: explicitly compare pointers to NULL
This patch was generated by the following semantic patch (http://coccinelle.lip6.fr/) // <smpl> @fix disable is_null,isnt_null1@ expression *E; @@ - !E + E == NULL // </smpl>
Diffstat (limited to 'gatchat')
-rw-r--r--gatchat/gatchat.c52
-rw-r--r--gatchat/gathdlc.c8
-rw-r--r--gatchat/gatio.c4
-rw-r--r--gatchat/gatmux.c6
-rw-r--r--gatchat/gatppp.c4
-rw-r--r--gatchat/gatresult.c44
-rw-r--r--gatchat/gatserver.c16
-rw-r--r--gatchat/gatutil.c6
-rw-r--r--gatchat/gsmdial.c2
-rw-r--r--gatchat/ppp_auth.c6
-rw-r--r--gatchat/ppp_cp.c4
-rw-r--r--gatchat/ppp_ipcp.c4
-rw-r--r--gatchat/ppp_lcp.c6
-rw-r--r--gatchat/ringbuffer.c14
-rw-r--r--gatchat/test-qcdm.c6
-rw-r--r--gatchat/test-server.c18
16 files changed, 98 insertions, 102 deletions
diff --git a/gatchat/gatchat.c b/gatchat/gatchat.c
index 218f5921..d82a02ea 100644
--- a/gatchat/gatchat.c
+++ b/gatchat/gatchat.c
@@ -253,12 +253,12 @@ static struct at_command *at_command_create(guint gid, const char *cmd,
}
c = g_try_new0(struct at_command, 1);
- if (!c)
+ if (c == NULL)
return 0;
len = strlen(cmd);
c->cmd = g_try_new(char, len + 2);
- if (!c->cmd) {
+ if (c->cmd == NULL) {
g_free(c);
return 0;
}
@@ -408,7 +408,7 @@ static gboolean at_chat_match_notify(struct at_chat *chat, char *line)
return TRUE;
}
- if (!result.lines)
+ if (result.lines == NULL)
result.lines = g_slist_prepend(NULL, line);
g_slist_foreach(notify->nodes, at_notify_call_callback,
@@ -434,7 +434,7 @@ static void at_chat_finish_command(struct at_chat *p, gboolean ok, char *final)
GSList *response_lines;
/* Cannot happen, but lets be paranoid */
- if (!cmd)
+ if (cmd == NULL)
return;
p->cmd_bytes_written = 0;
@@ -567,7 +567,7 @@ static void have_line(struct at_chat *p, char *str)
/* We're not going to copy terminal <CR><LF> */
struct at_command *cmd;
- if (!str)
+ if (str == NULL)
return;
/* Check for echo, this should not happen, but lets be paranoid */
@@ -638,7 +638,7 @@ static void have_pdu(struct at_chat *p, char *pdu)
GAtResult result;
gboolean listing_pdu = FALSE;
- if (!pdu)
+ if (pdu == NULL)
goto error;
result.lines = g_slist_prepend(NULL, p->pdu_notify);
@@ -703,7 +703,7 @@ static char *extract_line(struct at_chat *p, struct ring_buffer *rbuf)
}
line = g_try_new(char, line_length + 1);
- if (!line) {
+ if (line == NULL) {
ring_buffer_drain(rbuf, p->read_so_far);
return NULL;
}
@@ -800,10 +800,10 @@ static gboolean wakeup_no_response(gpointer user_data)
return FALSE;
at_chat_finish_command(chat, FALSE, NULL);
+
cmd = at_command_create(0, chat->wakeup, none_prefix, FALSE,
NULL, wakeup_cb, chat, NULL, TRUE);
-
- if (!cmd) {
+ if (cmd == NULL) {
chat->timeout_source = 0;
return FALSE;
}
@@ -842,7 +842,7 @@ static gboolean can_write_data(gpointer data)
return FALSE;
if (chat->wakeup) {
- if (!chat->wakeup_timer) {
+ if (chat->wakeup_timer == NULL) {
wakeup_first = TRUE;
chat->wakeup_timer = g_timer_new();
@@ -854,8 +854,7 @@ static gboolean can_write_data(gpointer data)
if (chat->cmd_bytes_written == 0 && wakeup_first == TRUE) {
cmd = at_command_create(0, chat->wakeup, none_prefix, FALSE,
NULL, wakeup_cb, chat, NULL, TRUE);
-
- if (!cmd)
+ if (cmd == NULL)
return FALSE;
g_queue_push_head(chat->command_queue, cmd);
@@ -1005,8 +1004,7 @@ static guint at_chat_send_common(struct at_chat *chat, guint gid,
c = at_command_create(gid, cmd, prefix_list, expect_pdu, listing, func,
user_data, notify, FALSE);
-
- if (!c)
+ if (c == NULL)
return 0;
c->id = chat->next_cmd_id++;
@@ -1027,12 +1025,11 @@ static struct at_notify *at_notify_create(struct at_chat *chat,
char *key;
key = g_strdup(prefix);
-
- if (!key)
+ if (key == NULL)
return 0;
notify = g_try_new0(struct at_notify, 1);
- if (!notify) {
+ if (notify == NULL) {
g_free(key);
return 0;
}
@@ -1055,7 +1052,7 @@ static gboolean at_chat_cancel(struct at_chat *chat, guint group, guint id)
l = g_queue_find_custom(chat->command_queue, GUINT_TO_POINTER(id),
at_command_compare_by_id);
- if (!l)
+ if (l == NULL)
return FALSE;
c = l->data;
@@ -1124,14 +1121,14 @@ static guint at_chat_register(struct at_chat *chat, guint group,
notify = g_hash_table_lookup(chat->notify_list, prefix);
- if (!notify)
+ if (notify == NULL)
notify = at_notify_create(chat, prefix, expect_pdu);
- if (!notify || notify->pdu != expect_pdu)
+ if (notify == NULL || notify->pdu != expect_pdu)
return 0;
node = g_try_new0(struct at_notify_node, 1);
- if (!node)
+ if (node == NULL)
return 0;
node->id = chat->next_notify_id++;
@@ -1165,7 +1162,7 @@ static gboolean at_chat_unregister(struct at_chat *chat, gboolean mark_only,
l = g_slist_find_custom(notify->nodes, GUINT_TO_POINTER(id),
at_notify_node_compare_by_id);
- if (!l)
+ if (l == NULL)
continue;
node = l->data;
@@ -1206,14 +1203,14 @@ static struct at_chat *create_chat(GIOChannel *channel, GIOFlags flags,
{
struct at_chat *chat;
- if (!channel)
+ if (channel == NULL)
return NULL;
- if (!syntax)
+ if (syntax == NULL)
return NULL;
chat = g_try_new0(struct at_chat, 1);
- if (!chat)
+ if (chat == NULL)
return chat;
chat->ref_count = 1;
@@ -1226,14 +1223,13 @@ static struct at_chat *create_chat(GIOChannel *channel, GIOFlags flags,
else
chat->io = g_at_io_new_blocking(channel);
- if (!chat->io)
+ if (chat->io == NULL)
goto error;
g_at_io_set_disconnect_function(chat->io, io_disconnect, chat);
chat->command_queue = g_queue_new();
-
- if (!chat->command_queue)
+ if (chat->command_queue == NULL)
goto error;
chat->notify_list = g_hash_table_new_full(g_str_hash, g_str_equal,
diff --git a/gatchat/gathdlc.c b/gatchat/gathdlc.c
index 37f014aa..dd11043c 100644
--- a/gatchat/gathdlc.c
+++ b/gatchat/gathdlc.c
@@ -256,7 +256,7 @@ GAtHDLC *g_at_hdlc_new(GIOChannel *channel)
GAtHDLC *g_at_hdlc_ref(GAtHDLC *hdlc)
{
- if (!hdlc)
+ if (hdlc == NULL)
return NULL;
g_atomic_int_inc(&hdlc->ref_count);
@@ -266,7 +266,7 @@ GAtHDLC *g_at_hdlc_ref(GAtHDLC *hdlc)
void g_at_hdlc_unref(GAtHDLC *hdlc)
{
- if (!hdlc)
+ if (hdlc == NULL)
return;
if (g_atomic_int_dec_and_test(&hdlc->ref_count) == FALSE)
@@ -291,7 +291,7 @@ void g_at_hdlc_unref(GAtHDLC *hdlc)
void g_at_hdlc_set_debug(GAtHDLC *hdlc, GAtDebugFunc func, gpointer user_data)
{
- if (!hdlc)
+ if (hdlc == NULL)
return;
hdlc->debugf = func;
@@ -301,7 +301,7 @@ void g_at_hdlc_set_debug(GAtHDLC *hdlc, GAtDebugFunc func, gpointer user_data)
void g_at_hdlc_set_receive(GAtHDLC *hdlc, GAtReceiveFunc func,
gpointer user_data)
{
- if (!hdlc)
+ if (hdlc == NULL)
return;
hdlc->receive_func = func;
diff --git a/gatchat/gatio.c b/gatchat/gatio.c
index a9faba50..b65be86d 100644
--- a/gatchat/gatio.c
+++ b/gatchat/gatio.c
@@ -177,11 +177,11 @@ static GAtIO *create_io(GIOChannel *channel, GIOFlags flags)
{
GAtIO *io;
- if (!channel)
+ if (channel == NULL)
return NULL;
io = g_try_new0(GAtIO, 1);
- if (!io)
+ if (io == NULL)
return io;
io->ref_count = 1;
diff --git a/gatchat/gatmux.c b/gatchat/gatmux.c
index fb912e63..9aed9879 100644
--- a/gatchat/gatmux.c
+++ b/gatchat/gatmux.c
@@ -414,7 +414,7 @@ static gboolean watch_dispatch(GSource *source, GSourceFunc callback,
GAtMuxWatch *watch = (GAtMuxWatch *) source;
GAtMuxChannel *channel = (GAtMuxChannel *) watch->channel;
- if (!func)
+ if (func == NULL)
return FALSE;
return func(watch->channel, channel->condition & watch->condition,
@@ -554,11 +554,11 @@ GAtMux *g_at_mux_new(GIOChannel *channel, const GAtMuxDriver *driver)
{
GAtMux *mux;
- if (!channel)
+ if (channel == NULL)
return NULL;
mux = g_try_new0(GAtMux, 1);
- if (!mux)
+ if (mux == NULL)
return NULL;
mux->ref_count = 1;
diff --git a/gatchat/gatppp.c b/gatchat/gatppp.c
index 5e875b8a..bbd8ab1a 100644
--- a/gatchat/gatppp.c
+++ b/gatchat/gatppp.c
@@ -78,7 +78,7 @@ struct _GAtPPP {
void ppp_debug(GAtPPP *ppp, const char *str)
{
- if (!ppp || !ppp->debugf)
+ if (ppp == NULL || ppp->debugf == NULL)
return;
ppp->debugf(str, ppp->debug_data);
@@ -490,7 +490,7 @@ static GAtPPP *ppp_init_common(GAtHDLC *hdlc, gboolean is_server, guint32 ip)
GAtPPP *ppp;
ppp = g_try_malloc0(sizeof(GAtPPP));
- if (!ppp)
+ if (ppp == NULL)
return NULL;
ppp->hdlc = g_at_hdlc_ref(hdlc);
diff --git a/gatchat/gatresult.c b/gatchat/gatresult.c
index cd7ec716..8a6dfae4 100644
--- a/gatchat/gatresult.c
+++ b/gatchat/gatresult.c
@@ -81,10 +81,10 @@ const char *g_at_result_iter_raw_line(GAtResultIter *iter)
{
const char *line;
- if (!iter)
+ if (iter == NULL)
return NULL;
- if (!iter->l)
+ if (iter->l == NULL)
return NULL;
line = iter->l->data;
@@ -113,10 +113,10 @@ gboolean g_at_result_iter_next_unquoted_string(GAtResultIter *iter,
unsigned int len;
char *line;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -157,10 +157,10 @@ gboolean g_at_result_iter_next_string(GAtResultIter *iter, const char **str)
unsigned int len;
char *line;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -209,10 +209,10 @@ gboolean g_at_result_iter_next_hexstring(GAtResultIter *iter,
char *line;
char *bufpos;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -264,10 +264,10 @@ gboolean g_at_result_iter_next_number(GAtResultIter *iter, gint *number)
int value = 0;
char *line;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -301,10 +301,10 @@ gboolean g_at_result_iter_next_range(GAtResultIter *iter, gint *min, gint *max)
int high = 0;
char *line;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -391,10 +391,10 @@ gboolean g_at_result_iter_skip_next(GAtResultIter *iter)
unsigned int skipped_to;
char *line;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -414,10 +414,10 @@ gboolean g_at_result_iter_open_list(GAtResultIter *iter)
char *line;
unsigned int len;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -443,10 +443,10 @@ gboolean g_at_result_iter_close_list(GAtResultIter *iter)
char *line;
unsigned int len;
- if (!iter)
+ if (iter == NULL)
return FALSE;
- if (!iter->l)
+ if (iter->l == NULL)
return FALSE;
line = iter->l->data;
@@ -467,7 +467,7 @@ gboolean g_at_result_iter_close_list(GAtResultIter *iter)
const char *g_at_result_final_response(GAtResult *result)
{
- if (!result)
+ if (result == NULL)
return NULL;
return result->final_or_pdu;
@@ -475,7 +475,7 @@ const char *g_at_result_final_response(GAtResult *result)
const char *g_at_result_pdu(GAtResult *result)
{
- if (!result)
+ if (result == NULL)
return NULL;
return result->final_or_pdu;
@@ -483,10 +483,10 @@ const char *g_at_result_pdu(GAtResult *result)
gint g_at_result_num_response_lines(GAtResult *result)
{
- if (!result)
+ if (result == NULL)
return 0;
- if (!result->lines)
+ if (result->lines == NULL)
return 0;
return g_slist_length(result->lines);
diff --git a/gatchat/gatserver.c b/gatchat/gatserver.c
index 49e0de49..11eaac61 100644
--- a/gatchat/gatserver.c
+++ b/gatchat/gatserver.c
@@ -128,7 +128,7 @@ static struct ring_buffer *allocate_next(GAtServer *server)
{
struct ring_buffer *buf = ring_buffer_new(BUF_SIZE);
- if (!buf)
+ if (buf == NULL)
return NULL;
g_queue_push_tail(server->write_queue, buf);
@@ -812,7 +812,7 @@ static char *extract_line(GAtServer *p, struct ring_buffer *rbuf)
line_length -= 3;
line = g_try_new(char, line_length + 1);
- if (!line) {
+ if (line == NULL) {
ring_buffer_drain(rbuf, p->read_so_far);
return NULL;
}
@@ -1066,11 +1066,11 @@ GAtServer *g_at_server_new(GIOChannel *io)
{
GAtServer *server;
- if (!io)
+ if (io == NULL)
return NULL;
server = g_try_new0(GAtServer, 1);
- if (!server)
+ if (server == NULL)
return NULL;
server->ref_count = 1;
@@ -1089,7 +1089,7 @@ GAtServer *g_at_server_new(GIOChannel *io)
if (!server->write_queue)
goto error;
- if (!allocate_next(server))
+ if (allocate_next(server) == NULL)
goto error;
server->max_read_attempts = 3;
@@ -1207,7 +1207,7 @@ void g_at_server_unref(GAtServer *server)
gboolean g_at_server_shutdown(GAtServer *server)
{
- if (!server)
+ if (server == NULL)
return FALSE;
/* Don't trigger user disconnect on shutdown */
@@ -1259,7 +1259,7 @@ gboolean g_at_server_register(GAtServer *server, char *prefix,
return FALSE;
node = g_try_new0(struct at_command, 1);
- if (!node)
+ if (node == NULL)
return FALSE;
node->notify = notify;
@@ -1282,7 +1282,7 @@ gboolean g_at_server_unregister(GAtServer *server, const char *prefix)
return FALSE;
node = g_hash_table_lookup(server->command_list, prefix);
- if (!node)
+ if (node == NULL)
return FALSE;
g_hash_table_remove(server->command_list, prefix);
diff --git a/gatchat/gatutil.c b/gatchat/gatutil.c
index 827dc60c..393d94cb 100644
--- a/gatchat/gatutil.c
+++ b/gatchat/gatutil.c
@@ -42,7 +42,7 @@ void g_at_util_debug_chat(gboolean in, const char *str, gsize len,
gsize ctrlz_size = strlen(ctrlz);
gsize i;
- if (!debugf || !len)
+ if (debugf == NULL || !len)
return;
for (i = 0; i < len; i++) {
@@ -116,11 +116,11 @@ void g_at_util_debug_dump(gboolean in, const unsigned char *buf, gsize len,
GString *str;
gsize i;
- if (!debugf || !len)
+ if (debugf == NULL || !len)
return;
str = g_string_sized_new(1 + (len * 2));
- if (!str)
+ if (str == NULL)
return;
g_string_append_c(str, type);
diff --git a/gatchat/gsmdial.c b/gatchat/gsmdial.c
index 57d0d9e9..22ff2ff2 100644
--- a/gatchat/gsmdial.c
+++ b/gatchat/gsmdial.c
@@ -303,7 +303,7 @@ static void connect_cb(gboolean ok, GAtResult *result, gpointer user_data)
/* open ppp */
ppp = g_at_ppp_new_from_io(io);
- if (!ppp) {
+ if (ppp == NULL) {
g_print("Unable to create PPP object\n");
exit(1);
}
diff --git a/gatchat/ppp_auth.c b/gatchat/ppp_auth.c
index d26b764e..fca873ca 100644
--- a/gatchat/ppp_auth.c
+++ b/gatchat/ppp_auth.c
@@ -66,7 +66,7 @@ static void chap_process_challenge(struct ppp_chap *chap, const guint8 *packet)
/* create a checksum over id, secret, and challenge */
checksum = g_checksum_new(chap->method);
- if (!checksum)
+ if (checksum == NULL)
return;
g_checksum_update(checksum, &header->identifier, 1);
@@ -84,7 +84,7 @@ static void chap_process_challenge(struct ppp_chap *chap, const guint8 *packet)
digest_len = g_checksum_type_get_length(chap->method);
response_length = digest_len + sizeof(*header) + 1;
ppp_packet = ppp_packet_new(response_length, CHAP_PROTOCOL);
- if (!ppp_packet)
+ if (ppp_packet == NULL)
goto challenge_out;
response = (struct chap_header *) &ppp_packet->info;
@@ -144,7 +144,7 @@ struct ppp_chap *ppp_chap_new(GAtPPP *ppp, guint8 method)
return NULL;
chap = g_try_new0(struct ppp_chap, 1);
- if (!chap)
+ if (chap == NULL)
return NULL;
chap->ppp = ppp;
diff --git a/gatchat/ppp_cp.c b/gatchat/ppp_cp.c
index f6220d2c..31ea05ad 100644
--- a/gatchat/ppp_cp.c
+++ b/gatchat/ppp_cp.c
@@ -205,7 +205,7 @@ static struct pppcp_packet *pppcp_packet_new(struct pppcp_data *data,
guint16 packet_length = bufferlen + sizeof(*packet);
ppp_packet = ppp_packet_new(packet_length, data->driver->proto);
- if (!ppp_packet)
+ if (ppp_packet == NULL)
return NULL;
/* advance past protocol to add CP header information */
@@ -1002,7 +1002,7 @@ struct pppcp_data *pppcp_new(GAtPPP *ppp, const struct pppcp_proto *proto,
struct pppcp_data *data;
data = g_try_malloc0(sizeof(struct pppcp_data));
- if (!data)
+ if (data == NULL)
return NULL;
if (dormant)
diff --git a/gatchat/ppp_ipcp.c b/gatchat/ppp_ipcp.c
index 3aa9eece..3e4f73be 100644
--- a/gatchat/ppp_ipcp.c
+++ b/gatchat/ppp_ipcp.c
@@ -471,7 +471,7 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp, gboolean is_server, guint32 ip)
struct pppcp_data *pppcp;
ipcp = g_try_new0(struct ipcp_data, 1);
- if (!ipcp)
+ if (ipcp == NULL)
return NULL;
/*
@@ -481,7 +481,7 @@ struct pppcp_data *ipcp_new(GAtPPP *ppp, gboolean is_server, guint32 ip)
* as rejects.
*/
pppcp = pppcp_new(ppp, &ipcp_proto, FALSE, MAX_IPCP_FAILURE);
- if (!pppcp) {
+ if (pppcp == NULL) {
g_printerr("Failed to allocate PPPCP struct\n");
g_free(ipcp);
return NULL;
diff --git a/gatchat/ppp_lcp.c b/gatchat/ppp_lcp.c
index 5838ebda..3a80a624 100644
--- a/gatchat/ppp_lcp.c
+++ b/gatchat/ppp_lcp.c
@@ -225,7 +225,7 @@ static enum rcr_result lcp_rcr(struct pppcp_data *pppcp,
*/
option = g_try_malloc0(5);
- if (!option)
+ if (option == NULL)
return RCR_REJECT;
option[0] = AUTH_PROTO;
@@ -310,11 +310,11 @@ struct pppcp_data *lcp_new(GAtPPP *ppp, gboolean is_server)
struct lcp_data *lcp;
lcp = g_try_new0(struct lcp_data, 1);
- if (!lcp)
+ if (lcp == NULL)
return NULL;
pppcp = pppcp_new(ppp, &lcp_proto, is_server, 0);
- if (!pppcp) {
+ if (pppcp == NULL) {
g_free(lcp);
return NULL;
}
diff --git a/gatchat/ringbuffer.c b/gatchat/ringbuffer.c
index 5e9b6340..becd3f8f 100644
--- a/gatchat/ringbuffer.c
+++ b/gatchat/ringbuffer.c
@@ -51,11 +51,11 @@ struct ring_buffer *ring_buffer_new(unsigned int size)
return NULL;
buffer = g_try_new(struct ring_buffer, 1);
- if (!buffer)
+ if (buffer == NULL)
return NULL;
buffer->buffer = g_try_new(unsigned char, real_size);
- if (!buffer->buffer) {
+ if (buffer->buffer == NULL) {
g_free(buffer);
return NULL;
}
@@ -164,7 +164,7 @@ unsigned char *ring_buffer_read_ptr(struct ring_buffer *buf,
int ring_buffer_len(struct ring_buffer *buf)
{
- if (!buf)
+ if (buf == NULL)
return -1;
return buf->in - buf->out;
@@ -172,7 +172,7 @@ int ring_buffer_len(struct ring_buffer *buf)
void ring_buffer_reset(struct ring_buffer *buf)
{
- if (!buf)
+ if (buf == NULL)
return;
buf->in = 0;
@@ -181,7 +181,7 @@ void ring_buffer_reset(struct ring_buffer *buf)
int ring_buffer_avail(struct ring_buffer *buf)
{
- if (!buf)
+ if (buf == NULL)
return -1;
return buf->size - buf->in + buf->out;
@@ -189,7 +189,7 @@ int ring_buffer_avail(struct ring_buffer *buf)
int ring_buffer_capacity(struct ring_buffer *buf)
{
- if (!buf)
+ if (buf == NULL)
return -1;
return buf->size;
@@ -197,7 +197,7 @@ int ring_buffer_capacity(struct ring_buffer *buf)
void ring_buffer_free(struct ring_buffer *buf)
{
- if (!buf)
+ if (buf == NULL)
return;
g_free(buf->buffer);
diff --git a/gatchat/test-qcdm.c b/gatchat/test-qcdm.c
index c8a31748..a15ea9ce 100644
--- a/gatchat/test-qcdm.c
+++ b/gatchat/test-qcdm.c
@@ -161,13 +161,13 @@ int main(int argc, char **argv)
g_option_context_free(context);
- if (!option_device)
+ if (option_device == NULL)
option_device = g_strdup("/dev/ttyUSB1");
g_print("Device: %s\n", option_device);
channel = g_at_tty_open(option_device, NULL);
- if (!channel) {
+ if (channel == NULL) {
g_printerr("Failed to open QCDM device\n");
return 1;
}
@@ -178,7 +178,7 @@ int main(int argc, char **argv)
g_io_channel_unref(channel);
- if (!hdlc)
+ if (hdlc == NULL)
return 1;
if (option_debug == TRUE)
diff --git a/gatchat/test-server.c b/gatchat/test-server.c
index c405f41c..cb451e91 100644
--- a/gatchat/test-server.c
+++ b/gatchat/test-server.c
@@ -793,7 +793,7 @@ static void dial_cb(GAtServerRequestType type, GAtResult *cmd, gpointer user)
goto error;
dial_str = g_at_result_iter_raw_line(&iter);
- if (!dial_str)
+ if (dial_str == NULL)
goto error;
g_print("dial call %s\n", dial_str);
@@ -861,7 +861,7 @@ static gboolean create_tty(const char *modem_path)
char pty_name[256];
GIOChannel *server_io;
- if (!modem_path)
+ if (modem_path == NULL)
return FALSE;
if (openpty(&master, &slave, pty_name, NULL, NULL) < 0)
@@ -874,7 +874,7 @@ static gboolean create_tty(const char *modem_path)
server_io = g_io_channel_unix_new(master);
server = g_at_server_new(server_io);
- if (!server) {
+ if (server == NULL) {
g_io_channel_shutdown(server_io, FALSE, NULL);
g_io_channel_unref(server_io);
@@ -907,7 +907,7 @@ static gboolean on_socket_connected(GIOChannel *chan, GIOCondition cond,
server = g_at_server_new(client_io);
g_io_channel_unref(client_io);
- if (!server)
+ if (server == NULL)
goto error;
add_handler(server);
@@ -946,7 +946,7 @@ static struct sock_server *socket_common(int sk, struct sockaddr *addr,
}
sock = g_try_new0(struct sock_server, 1);
- if (!sock)
+ if (sock == NULL)
return FALSE;
sock->server_sock = sk;
@@ -961,7 +961,7 @@ static gboolean create_tcp(const char *modem_path, int port)
struct sock_server *server;
GIOChannel *server_io;
- if (!modem_path)
+ if (modem_path == NULL)
return FALSE;
sk = socket(PF_INET, SOCK_STREAM, 0);
@@ -978,7 +978,7 @@ static gboolean create_tcp(const char *modem_path, int port)
addr.sin_port = htons(port);
server = socket_common(sk, (struct sockaddr *) &addr, modem_path);
- if (!server)
+ if (server == NULL)
return FALSE;
g_print("new tcp is created at tcp port %d\n", port);
@@ -1004,7 +1004,7 @@ static gboolean create_unix(const char *modem_path, const char *sock_path)
struct sock_server *server;
GIOChannel *server_io;
- if (!modem_path)
+ if (modem_path == NULL)
return FALSE;
sk = socket(AF_UNIX, SOCK_STREAM, 0);
@@ -1024,7 +1024,7 @@ static gboolean create_unix(const char *modem_path, const char *sock_path)
unlink(addr.sun_path);
server = socket_common(sk, (struct sockaddr *) &addr, modem_path);
- if (!server)
+ if (server == NULL)
return FALSE;
g_print("new unix socket is created at %s\n", sock_path);