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


Ignore:
Timestamp:
2018-03-02T20:10:49Z (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:
f1380b7
Parents:
3061bc1
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-02-28 17:38:31)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-03-02 20:10:49)
Message:

style: Remove trailing whitespace on _all_ lines, including empty ones, for particular file types.

Command used: tools/srepl '\s\+$' '' -- *.c *.h *.py *.sh *.s *.S *.ag

Currently, whitespace on empty lines is very inconsistent.
There are two basic choices: Either remove the whitespace, or keep empty lines
indented to the level of surrounding code. The former is AFAICT more common,
and also much easier to do automatically.

Alternatively, we could write script for automatic indentation, and use that
instead. However, if such a script exists, it's possible to use the indented
style locally, by having the editor apply relevant conversions on load/save,
without affecting remote repository. IMO, it makes more sense to adopt
the simpler rule.

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

Legend:

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

    r3061bc1 ra35b458  
    298298{
    299299        assert(buf_size >= 4);
    300        
     300
    301301        uint32_t w = ((uint32_t) buf[0] << 24) +
    302302            ((uint32_t) buf[1] << 16) +
    303303            ((uint32_t) buf[2] << 8) +
    304304            buf[3];
    305        
     305
    306306        return w;
    307307}
     
    311311{
    312312        assert(buf_size >= 16);
    313        
     313
    314314        addr128_t_be2host(buf, addr);
    315315}
  • uspace/srv/net/dnsrsrv/dnsrsrv.c

    r3061bc1 ra35b458  
    9090{
    9191        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srvaddr_srv()");
    92        
     92
    9393        ip_ver_t ver = IPC_GET_ARG1(*icall);
    94        
     94
    9595        char *name;
    9696        errno_t rc = async_data_write_accept((void **) &name, true, 0,
     
    100100                return;
    101101        }
    102        
     102
    103103        dns_host_info_t *hinfo;
    104104        rc = dns_name2host(name, &hinfo, ver);
     
    107107                return;
    108108        }
    109        
     109
    110110        ipc_callid_t callid;
    111111        size_t size;
     
    115115                return;
    116116        }
    117        
     117
    118118        if (size != sizeof(inet_addr_t)) {
    119119                async_answer_0(callid, EINVAL);
     
    121121                return;
    122122        }
    123        
     123
    124124        rc = async_data_read_finalize(callid, &hinfo->addr, size);
    125125        if (rc != EOK) {
     
    128128                return;
    129129        }
    130        
     130
    131131        if (!async_data_read_receive(&callid, &size)) {
    132132                async_answer_0(callid, EREFUSED);
     
    134134                return;
    135135        }
    136        
     136
    137137        size_t act_size = str_size(hinfo->cname);
    138138        if (act_size > size) {
     
    141141                return;
    142142        }
    143        
     143
    144144        rc = async_data_read_finalize(callid, hinfo->cname, act_size);
    145145        if (rc != EOK)
    146146                async_answer_0(callid, rc);
    147        
     147
    148148        async_answer_0(iid, rc);
    149        
     149
    150150        dns_hostinfo_destroy(hinfo);
    151151}
     
    155155{
    156156        log_msg(LOG_DEFAULT, LVL_DEBUG, "inet_get_srvaddr_srv()");
    157        
     157
    158158        ipc_callid_t callid;
    159159        size_t size;
     
    163163                return;
    164164        }
    165        
     165
    166166        if (size != sizeof(inet_addr_t)) {
    167167                async_answer_0(callid, EINVAL);
     
    169169                return;
    170170        }
    171        
     171
    172172        // FIXME locking
    173        
     173
    174174        errno_t rc = async_data_read_finalize(callid, &dns_server_addr, size);
    175175        if (rc != EOK)
    176176                async_answer_0(callid, rc);
    177        
     177
    178178        async_answer_0(iid, rc);
    179179}
     
    183183{
    184184        log_msg(LOG_DEFAULT, LVL_DEBUG, "dnsr_set_srvaddr_srv()");
    185        
     185
    186186        ipc_callid_t callid;
    187187        size_t size;
     
    191191                return;
    192192        }
    193        
     193
    194194        if (size != sizeof(inet_addr_t)) {
    195195                async_answer_0(callid, EINVAL);
     
    197197                return;
    198198        }
    199        
     199
    200200        // FIXME locking
    201        
     201
    202202        errno_t rc = async_data_write_finalize(callid, &dns_server_addr, size);
    203203        if (rc != EOK) {
     
    205205                async_answer_0(iid, rc);
    206206        }
    207        
     207
    208208        async_answer_0(iid, rc);
    209209}
  • uspace/srv/net/dnsrsrv/query.c

    r3061bc1 ra35b458  
    5454        if (sname == NULL)
    5555                return ENOMEM;
    56        
     56
    5757        char *qname = str_dup(name);
    5858        if (qname == NULL) {
     
    6060                return ENOMEM;
    6161        }
    62        
     62
    6363        dns_question_t *question = calloc(1, sizeof(dns_question_t));
    6464        if (question == NULL) {
     
    6767                return ENOMEM;
    6868        }
    69        
     69
    7070        question->qname = qname;
    7171        question->qtype = qtype;
    7272        question->qclass = DC_IN;
    73        
     73
    7474        dns_message_t *msg = dns_message_new();
    7575        if (msg == NULL) {
     
    7979                return ENOMEM;
    8080        }
    81        
     81
    8282        msg->id = msg_id++;
    8383        msg->qr = QR_QUERY;
     
    8787        msg->rd = true;
    8888        msg->ra = false;
    89        
     89
    9090        list_append(&question->msg, &msg->question);
    91        
     91
    9292        log_msg(LOG_DEFAULT, LVL_DEBUG, "dns_name_query: send DNS request");
    9393        dns_message_t *amsg;
     
    9898                return rc;
    9999        }
    100        
     100
    101101        list_foreach(amsg->answer, msg, dns_rr_t, rr) {
    102102                log_msg(LOG_DEFAULT, LVL_DEBUG, " - '%s' %u/%u, dsize %zu",
    103103                    rr->name, rr->rtype, rr->rclass, rr->rdata_size);
    104                
     104
    105105                if ((rr->rtype == DTYPE_CNAME) && (rr->rclass == DC_IN) &&
    106106                    (str_cmp(rr->name, sname) == 0)) {
    107                        
     107
    108108                        log_msg(LOG_DEFAULT, LVL_DEBUG, "decode cname (%p, %zu, %zu)",
    109109                            amsg->pdu.data, amsg->pdu.size, rr->roff);
    110                        
     110
    111111                        char *cname;
    112112                        size_t eoff;
     
    114114                        if (rc != EOK) {
    115115                                assert((rc == EINVAL) || (rc == ENOMEM));
    116                                
     116
    117117                                log_msg(LOG_DEFAULT, LVL_DEBUG, "error decoding cname");
    118                                
     118
    119119                                dns_message_destroy(msg);
    120120                                dns_message_destroy(amsg);
    121121                                free(sname);
    122                                
     122
    123123                                return rc;
    124124                        }
    125                        
     125
    126126                        log_msg(LOG_DEFAULT, LVL_DEBUG, "name = '%s' "
    127127                            "cname = '%s'", sname, cname);
    128                        
     128
    129129                        /* Continue looking for the more canonical name */
    130130                        free(sname);
    131131                        sname = cname;
    132132                }
    133                
     133
    134134                if ((qtype == DTYPE_A) && (rr->rtype == DTYPE_A) &&
    135135                    (rr->rclass == DC_IN) && (rr->rdata_size == sizeof(addr32_t)) &&
    136136                    (str_cmp(rr->name, sname) == 0)) {
    137                        
     137
    138138                        info->cname = str_dup(rr->name);
    139139                        if (info->cname == NULL) {
     
    141141                                dns_message_destroy(amsg);
    142142                                free(sname);
    143                                
     143
    144144                                return ENOMEM;
    145145                        }
    146                        
     146
    147147                        inet_addr_set(dns_uint32_t_decode(rr->rdata, rr->rdata_size),
    148148                            &info->addr);
    149                        
     149
    150150                        dns_message_destroy(msg);
    151151                        dns_message_destroy(amsg);
    152152                        free(sname);
    153                        
     153
    154154                        return EOK;
    155155                }
    156                
     156
    157157                if ((qtype == DTYPE_AAAA) && (rr->rtype == DTYPE_AAAA) &&
    158158                    (rr->rclass == DC_IN) && (rr->rdata_size == sizeof(addr128_t)) &&
    159159                    (str_cmp(rr->name, sname) == 0)) {
    160                
     160
    161161                        info->cname = str_dup(rr->name);
    162162                        if (info->cname == NULL) {
     
    164164                                dns_message_destroy(amsg);
    165165                                free(sname);
    166                                
     166
    167167                                return ENOMEM;
    168168                        }
    169                        
     169
    170170                        addr128_t addr;
    171171                        dns_addr128_t_decode(rr->rdata, rr->rdata_size, addr);
    172                        
     172
    173173                        inet_addr_set6(addr, &info->addr);
    174                        
     174
    175175                        dns_message_destroy(msg);
    176176                        dns_message_destroy(amsg);
    177177                        free(sname);
    178                        
     178
    179179                        return EOK;
    180180                }
    181181        }
    182        
     182
    183183        log_msg(LOG_DEFAULT, LVL_DEBUG, "'%s' not resolved, fail", sname);
    184        
     184
    185185        dns_message_destroy(msg);
    186186        dns_message_destroy(amsg);
    187187        free(sname);
    188        
     188
    189189        return EIO;
    190190}
     
    195195        if (info == NULL)
    196196                return ENOMEM;
    197        
     197
    198198        errno_t rc;
    199        
     199
    200200        switch (ver) {
    201201        case ip_any:
    202202                rc = dns_name_query(name, DTYPE_AAAA, info);
    203                
     203
    204204                if (rc != EOK)
    205205                        rc = dns_name_query(name, DTYPE_A, info);
    206                
     206
    207207                break;
    208208        case ip_v4:
     
    215215                rc = EINVAL;
    216216        }
    217        
     217
    218218        if (rc == EOK)
    219219                *rinfo = info;
    220220        else
    221221                free(info);
    222        
     222
    223223        return rc;
    224224}
Note: See TracChangeset for help on using the changeset viewer.