Changeset b7fd2a0 in mainline for uspace/srv/net/dnsrsrv


Ignore:
Timestamp:
2018-01-13T03:10:29Z (8 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a53ed3a
Parents:
36f0738
Message:

Use errno_t in all uspace and kernel code.

Change type of every variable, parameter and return value that holds an
<errno.h> constant to either errno_t (the usual case), or sys_errno_t
(some places in kernel). This is for the purpose of self-documentation,
as well as for type-checking with a bit of type definition hackery.

Although this is a massive commit, it is a simple text replacement, and thus
is very easy to verify. Simply do the following:

`
git checkout <this commit's hash>
git reset HEAD
git add .
tools/srepl '\berrno_t\b' int
git add .
tools/srepl '\bsys_errno_t\b' sysarg_t
git reset
git diff
`

While this doesn't ensure that the replacements are correct, it does ensure
that the commit doesn't do anything except those replacements. Since errno_t
is typedef'd to int in the usual case (and sys_errno_t to sysarg_t), even if
incorrect, this commit cannot change behavior.

Location:
uspace/srv/net/dnsrsrv
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/net/dnsrsrv/dns_msg.c

    r36f0738 rb7fd2a0  
    5656 * fit in and append @a suff.
    5757 */
    58 static int dns_dstr_ext(char **dstr, const char *suff)
     58static errno_t dns_dstr_ext(char **dstr, const char *suff)
    5959{
    6060        size_t s1, s2;
     
    9393 * @param act_size      Place to store actual encoded size
    9494 */
    95 static int dns_name_encode(char *name, uint8_t *buf, size_t buf_size,
     95static errno_t dns_name_encode(char *name, uint8_t *buf, size_t buf_size,
    9696    size_t *act_size)
    9797{
     
    158158 * @param eoff  Place to store end offset (offset after last decoded byte)
    159159 */
    160 int dns_name_decode(dns_pdu_t *pdu, size_t boff, char **rname,
     160errno_t dns_name_decode(dns_pdu_t *pdu, size_t boff, char **rname,
    161161    size_t *eoff)
    162162{
     
    169169        char *name;
    170170        char dbuf[2];
    171         int rc;
     171        errno_t rc;
    172172        bool first;
    173173
     
    325325 * @param act_size      Place to store actual encoded size
    326326 */
    327 static int dns_question_encode(dns_question_t *question, uint8_t *buf,
     327static errno_t dns_question_encode(dns_question_t *question, uint8_t *buf,
    328328    size_t buf_size, size_t *act_size)
    329329{
    330330        size_t name_size;
    331331        size_t di;
    332         int rc;
     332        errno_t rc;
    333333
    334334        rc = dns_name_encode(question->qname, buf, buf_size, &name_size);
     
    358358 * @param eoff          Place to store end offset (offset after last decoded byte)
    359359 */
    360 static int dns_question_decode(dns_pdu_t *pdu, size_t boff,
     360static errno_t dns_question_decode(dns_pdu_t *pdu, size_t boff,
    361361    dns_question_t **rquestion, size_t *eoff)
    362362{
    363363        dns_question_t *question;
    364364        size_t name_eoff;
    365         int rc;
     365        errno_t rc;
    366366
    367367        question = calloc(1, sizeof (dns_question_t));
     
    398398 * @param eoff          Place to store end offset (offset after last decoded byte)
    399399 */
    400 static int dns_rr_decode(dns_pdu_t *pdu, size_t boff, dns_rr_t **retrr,
     400static errno_t dns_rr_decode(dns_pdu_t *pdu, size_t boff, dns_rr_t **retrr,
    401401    size_t *eoff)
    402402{
     
    406406        size_t bsz;
    407407        size_t rdlength;
    408         int rc;
     408        errno_t rc;
    409409
    410410        rr = calloc(1, sizeof(dns_rr_t));
     
    492492 *              ENOMEM if out of memory
    493493 */
    494 int dns_message_encode(dns_message_t *msg, void **rdata, size_t *rsize)
     494errno_t dns_message_encode(dns_message_t *msg, void **rdata, size_t *rsize)
    495495{
    496496        uint8_t *data;
     
    499499        size_t q_size = 0;
    500500        size_t di;
    501         int rc;
     501        errno_t rc;
    502502
    503503        hdr.id = host2uint16_t_be(msg->id);
     
    564564 *              ENOMEM if out of memory
    565565 */
    566 int dns_message_decode(void *data, size_t size, dns_message_t **rmsg)
     566errno_t dns_message_decode(void *data, size_t size, dns_message_t **rmsg)
    567567{
    568568        dns_message_t *msg;
     
    575575        size_t an_count;
    576576        size_t i;
    577         int rc;
     577        errno_t rc;
    578578
    579579        msg = dns_message_new();
  • uspace/srv/net/dnsrsrv/dns_msg.h

    r36f0738 rb7fd2a0  
    4444#include "dns_type.h"
    4545
    46 extern int dns_message_encode(dns_message_t *, void **, size_t *);
    47 extern int dns_message_decode(void *, size_t, dns_message_t **);
     46extern errno_t dns_message_encode(dns_message_t *, void **, size_t *);
     47extern errno_t dns_message_decode(void *, size_t, dns_message_t **);
    4848extern dns_message_t *dns_message_new(void);
    4949extern void dns_message_destroy(dns_message_t *);
    50 extern int dns_name_decode(dns_pdu_t *, size_t, char **, size_t *);
     50extern errno_t dns_name_decode(dns_pdu_t *, size_t, char **, size_t *);
    5151extern uint32_t dns_uint32_t_decode(uint8_t *, size_t);
    5252extern void dns_addr128_t_decode(uint8_t *, size_t, addr128_t);
  • uspace/srv/net/dnsrsrv/dnsrsrv.c

    r36f0738 rb7fd2a0  
    5454static void dnsr_client_conn(ipc_callid_t, ipc_call_t *, void *);
    5555
    56 static int dnsr_init(void)
    57 {
    58         int rc;
     56static errno_t dnsr_init(void)
     57{
     58        errno_t rc;
    5959        log_msg(LOG_DEFAULT, LVL_DEBUG, "dnsr_init()");
    6060
     
    9393       
    9494        char *name;
    95         int rc = async_data_write_accept((void **) &name, true, 0,
     95        errno_t rc = async_data_write_accept((void **) &name, true, 0,
    9696            DNS_NAME_MAX_SIZE, 0, NULL);
    9797        if (rc != EOK) {
     
    171171        // FIXME locking
    172172       
    173         int rc = async_data_read_finalize(callid, &dns_server_addr, size);
     173        errno_t rc = async_data_read_finalize(callid, &dns_server_addr, size);
    174174        if (rc != EOK)
    175175                async_answer_0(callid, rc);
     
    199199        // FIXME locking
    200200       
    201         int rc = async_data_write_finalize(callid, &dns_server_addr, size);
     201        errno_t rc = async_data_write_finalize(callid, &dns_server_addr, size);
    202202        if (rc != EOK) {
    203203                async_answer_0(callid, rc);
     
    246246int main(int argc, char *argv[])
    247247{
    248         int rc;
     248        errno_t rc;
    249249
    250250        printf("%s: DNS Resolution Service\n", NAME);
  • uspace/srv/net/dnsrsrv/query.c

    r36f0738 rb7fd2a0  
    4747static uint16_t msg_id;
    4848
    49 static int dns_name_query(const char *name, dns_qtype_t qtype,
     49static errno_t dns_name_query(const char *name, dns_qtype_t qtype,
    5050    dns_host_info_t *info)
    5151{
     
    9292        log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_name_query: send DNS request");
    9393        dns_message_t *amsg;
    94         int rc = dns_request(msg, &amsg);
     94        errno_t rc = dns_request(msg, &amsg);
    9595        if (rc != EOK) {
    9696                dns_message_destroy(msg);
     
    190190}
    191191
    192 int dns_name2host(const char *name, dns_host_info_t **rinfo, ip_ver_t ver)
     192errno_t dns_name2host(const char *name, dns_host_info_t **rinfo, ip_ver_t ver)
    193193{
    194194        dns_host_info_t *info = calloc(1, sizeof(dns_host_info_t));
     
    196196                return ENOMEM;
    197197       
    198         int rc;
     198        errno_t rc;
    199199       
    200200        switch (ver) {
  • uspace/srv/net/dnsrsrv/query.h

    r36f0738 rb7fd2a0  
    4040#include "dns_type.h"
    4141
    42 extern int dns_name2host(const char *, dns_host_info_t **, ip_ver_t);
     42extern errno_t dns_name2host(const char *, dns_host_info_t **, ip_ver_t);
    4343extern void dns_hostinfo_destroy(dns_host_info_t *);
    4444
  • uspace/srv/net/dnsrsrv/transport.c

    r36f0738 rb7fd2a0  
    6969        fibril_mutex_t done_lock;
    7070
    71         int status;
     71        errno_t status;
    7272} trans_req_t;
    7373
     
    9090};
    9191
    92 int transport_init(void)
     92errno_t transport_init(void)
    9393{
    9494        inet_ep2_t epp;
    95         int rc;
     95        errno_t rc;
    9696
    9797        inet_ep2_init(&epp);
     
    177177}
    178178
    179 int dns_request(dns_message_t *req, dns_message_t **rresp)
     179errno_t dns_request(dns_message_t *req, dns_message_t **rresp)
    180180{
    181181        trans_req_t *treq = NULL;
     
    185185        size_t req_size;
    186186        log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_request: Encode dns message");
    187         int rc = dns_message_encode(req, &req_data, &req_size);
     187        errno_t rc = dns_message_encode(req, &req_data, &req_size);
    188188        if (rc != EOK)
    189189                goto error;
     
    255255        size_t size;
    256256        inet_ep_t remote_ep;
    257         int rc;
     257        errno_t rc;
    258258
    259259        size = udp_rmsg_size(rmsg);
  • uspace/srv/net/dnsrsrv/transport.h

    r36f0738 rb7fd2a0  
    4242extern inet_addr_t dns_server_addr;
    4343
    44 extern int transport_init(void);
     44extern errno_t transport_init(void);
    4545extern void transport_fini(void);
    46 extern int dns_request(dns_message_t *, dns_message_t **);
     46extern errno_t dns_request(dns_message_t *, dns_message_t **);
    4747
    4848#endif
Note: See TracChangeset for help on using the changeset viewer.