Skip to content

Commit b4fddb4

Browse files
author
Levente Orban
committed
Move the includes to the .c file
1 parent 8541288 commit b4fddb4

File tree

2 files changed

+18
-17
lines changed

2 files changed

+18
-17
lines changed

jerry-core/debugger/jerry-debugger.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@
1414
*/
1515

1616
#include <errno.h>
17+
#include <arpa/inet.h>
18+
#include <unistd.h>
19+
#include <string.h>
20+
#include <stdbool.h>
1721

1822
#include "jerry-debugger.h"
1923
#include "jerry-port.h"
@@ -42,56 +46,58 @@ bool remote_init ()
4246
/* Create an endpoint for communication */
4347
if ((sock = socket (AF_INET, SOCK_STREAM, 0)) == -1)
4448
{
45-
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Socket error!\n");
49+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: %s\n", strerror (errno));
4650
return false;
4751
}
4852

4953
/* Set the options on socket */
5054
if (setsockopt (sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof (int)) == -1)
5155
{
52-
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Setsockopt error!\n");
56+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Erorr: %s\n", strerror (errno));
5357
return false;
5458
}
5559

5660
/* Bind to the server address */
5761
if (bind (sock, (struct sockaddr *)&server_addr, sizeof (struct sockaddr)) == -1)
5862
{
59-
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Bind error, unable to bind!\n");
63+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: %s\n", strerror (errno));
6064
return false;
6165
}
6266

6367
/* Listen for connections on socket */
6468
if (listen (sock, BACKLOG) == -1)
6569
{
66-
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Listen error!\n");
70+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: %s\n", strerror (errno));
6771
return false;
6872
}
6973

7074
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Waiting for the client connection.\n");
7175

7276
/* Connect from the client */
73-
connected = accept (sock, (struct sockaddr *)&client_addr, &sin_size);
77+
if ((connected = accept (sock, (struct sockaddr *)&client_addr, &sin_size)) == -1)
78+
{
79+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: %s\n", strerror (errno));
80+
return false;
81+
}
7482

75-
jerry_port_log (JERRY_LOG_LEVEL_DEBUG,"Connected from: %s:%d\n",
76-
inet_ntoa (client_addr.sin_addr),ntohs (client_addr.sin_port));
83+
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "Connected from: %s:%d\n",
84+
inet_ntoa (client_addr.sin_addr), ntohs (client_addr.sin_port));
7785

7886
return true;
7987
} /* remote_init */
8088

8189
/* Close the socket connection with the client */
8290
void connection_closed ()
8391
{
84-
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "TCPServer connection closed on port %d.\n", PORT);
92+
jerry_port_log (JERRY_LOG_LEVEL_DEBUG, "TCPServer connection closed on port: %d\n", PORT);
8593
close (connected);
8694
close (sock);
8795
} /* connection_closed */
8896

8997
/* Send the parsed file names to the client side */
9098
void send_to_client (uint16_t data_len) /**< data length */
9199
{
92-
ssize_t byte_send;
93-
94-
byte_send = send (connected, jerry_debugger_buffer, data_len, 0);
100+
ssize_t byte_send = send (connected, jerry_debugger_buffer, data_len, 0);
95101

96102
/* If send returns -1 then some error messages are generated by the socket layer. */
97103
if (byte_send == -1)
@@ -102,6 +108,6 @@ void send_to_client (uint16_t data_len) /**< data length */
102108
* information is sent to the client. */
103109
else if (byte_send != (ssize_t) data_len)
104110
{
105-
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error, missing bytes from the pacakge...\n");
111+
jerry_port_log (JERRY_LOG_LEVEL_ERROR, "Error: Missing bytes from the pacakge.\n");
106112
}
107113
} /* send_to_client */

jerry-core/debugger/jerry-debugger.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,6 @@
1616
#ifndef JERRY_DEBUGGER_H
1717
#define JERRY_DEBUGGER_H
1818

19-
#include <arpa/inet.h>
20-
#include <unistd.h>
21-
#include <string.h>
22-
#include <stdbool.h>
23-
2419
#define MAX_MESSAGE_SIZE 128
2520

2621
static uint8_t jerry_debugger_buffer[MAX_MESSAGE_SIZE];

0 commit comments

Comments
 (0)