Changeset a35b458 in mainline for uspace/srv/net/dnsrsrv/query.c


Ignore:
Timestamp:
2018-03-02T20:10:49Z (7 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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • 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.