~phablet-team/libdsme/master

« back to all changes in this revision

Viewing changes to protocol.c

  • Committer: Simo Piiroinen
  • Date: 2018-03-29 09:34:56 UTC
  • mto: This revision was merged to the branch mainline in revision 43.
  • Revision ID: git-v1:b661f44ee87b1a6df8658d229d71adefc930839e
[protocol] Set errno when abandoning dsmesock_send_with_extra()

Callers expect errno to be set when dsmesock_send_with_extra() - which
does not happen on error paths that bypass io altogether.

Set errno to ENOTCONN when doing early return due to invalid connection
state.

Also remove redundant parentheses.

Signed-off-by: Simo Piiroinen <simo.piiroinen@jollamobile.com>

Show diffs side-by-side

added added

removed removed

Lines of Context:
261
261
  /* Is this connection valid? */
262
262
  node = g_slist_find(connections, conn);
263
263
  if (node == 0 || conn->is_open == 0) {
 
264
    errno = ENOTCONN;
264
265
    return -1;
265
266
  }
266
267
 
267
268
  /* set up message header for sending */
268
 
  memcpy(&header, msg, sizeof(header));
 
269
  memcpy(&header, msg, sizeof header);
269
270
  buffers[count].iov_base = &header;
270
 
  buffers[count].iov_len  = sizeof(header);
 
271
  buffers[count].iov_len  = sizeof header;
271
272
  ++count;
272
273
 
273
274
  /* set up message body and existing extra data (if any) for sending */
274
 
  if (m->line_size_ > sizeof(header)) {
275
 
    buffers[count].iov_base = (void*)(((const char*)msg) + sizeof(header));
276
 
    buffers[count].iov_len  = m->line_size_ - sizeof(header);
 
275
  if (m->line_size_ > sizeof header) {
 
276
    buffers[count].iov_base = (void *)((const char*)msg + sizeof header);
 
277
    buffers[count].iov_len  = m->line_size_ - sizeof header;
277
278
    ++count;
278
279
  }
279
280