Changeset 46577995 in mainline for uspace/lib/c/generic/vbd.c


Ignore:
Timestamp:
2018-01-04T20:50:52Z (7 years ago)
Author:
Jiří Zárevúcky <zarevucky.jiri@…>
Children:
e211ea04
Parents:
facacc71
git-author:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:47:53)
git-committer:
Jiří Zárevúcky <zarevucky.jiri@…> (2018-01-04 20:50:52)
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.

After this commit, HelenOS is free of code that mixes error codes with non-error
values on the assumption that error codes are negative.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/c/generic/vbd.c

    rfacacc71 r46577995  
    4444#include <vbd.h>
    4545
    46 static int vbd_get_ids_internal(vbd_t *, sysarg_t, sysarg_t, sysarg_t **,
     46static errno_t vbd_get_ids_internal(vbd_t *, sysarg_t, sysarg_t, sysarg_t **,
    4747    size_t *);
    4848
    49 int vbd_create(vbd_t **rvbd)
     49errno_t vbd_create(vbd_t **rvbd)
    5050{
    5151        vbd_t *vbd;
    5252        service_id_t vbd_svcid;
    53         int rc;
     53        errno_t rc;
    5454
    5555        vbd = calloc(1, sizeof(vbd_t));
     
    9797 * @return EOK on success or an error code
    9898 */
    99 int vbd_get_disks(vbd_t *vbd, service_id_t **data, size_t *count)
     99errno_t vbd_get_disks(vbd_t *vbd, service_id_t **data, size_t *count)
    100100{
    101101        return vbd_get_ids_internal(vbd, VBD_GET_DISKS, 0, data, count);
     
    103103
    104104/** Get disk information. */
    105 int vbd_disk_info(vbd_t *vbd, service_id_t sid, vbd_disk_info_t *vinfo)
    106 {
    107         async_exch_t *exch;
    108         int retval;
     105errno_t vbd_disk_info(vbd_t *vbd, service_id_t sid, vbd_disk_info_t *vinfo)
     106{
     107        async_exch_t *exch;
     108        errno_t retval;
    109109        ipc_call_t answer;
    110110
    111111        exch = async_exchange_begin(vbd->sess);
    112112        aid_t req = async_send_1(exch, VBD_DISK_INFO, sid, &answer);
    113         int rc = async_data_read_start(exch, vinfo, sizeof(vbd_disk_info_t));
    114         async_exchange_end(exch);
    115 
    116         if (rc != EOK) {
    117                 async_forget(req);
    118                 return EIO;
    119         }
    120 
    121         async_wait_for(req, &retval);
    122         if (retval != EOK)
    123                 return EIO;
    124 
    125         return EOK;
    126 }
    127 
    128 int vbd_label_create(vbd_t *vbd, service_id_t sid, label_type_t ltype)
    129 {
    130         async_exch_t *exch;
    131         int retval;
     113        errno_t rc = async_data_read_start(exch, vinfo, sizeof(vbd_disk_info_t));
     114        async_exchange_end(exch);
     115
     116        if (rc != EOK) {
     117                async_forget(req);
     118                return EIO;
     119        }
     120
     121        async_wait_for(req, &retval);
     122        if (retval != EOK)
     123                return EIO;
     124
     125        return EOK;
     126}
     127
     128errno_t vbd_label_create(vbd_t *vbd, service_id_t sid, label_type_t ltype)
     129{
     130        async_exch_t *exch;
     131        errno_t retval;
    132132
    133133        exch = async_exchange_begin(vbd->sess);
     
    141141}
    142142
    143 int vbd_label_delete(vbd_t *vbd, service_id_t sid)
    144 {
    145         async_exch_t *exch;
    146         int retval;
     143errno_t vbd_label_delete(vbd_t *vbd, service_id_t sid)
     144{
     145        async_exch_t *exch;
     146        errno_t retval;
    147147
    148148        exch = async_exchange_begin(vbd->sess);
     
    167167 * @return EOK on success or an error code.
    168168 */
    169 static int vbd_get_ids_once(vbd_t *vbd, sysarg_t method, sysarg_t arg1,
     169static errno_t vbd_get_ids_once(vbd_t *vbd, sysarg_t method, sysarg_t arg1,
    170170    sysarg_t *id_buf, size_t buf_size, size_t *act_size)
    171171{
     
    174174        ipc_call_t answer;
    175175        aid_t req = async_send_1(exch, method, arg1, &answer);
    176         int rc = async_data_read_start(exch, id_buf, buf_size);
     176        errno_t rc = async_data_read_start(exch, id_buf, buf_size);
    177177
    178178        async_exchange_end(exch);
     
    183183        }
    184184
    185         int retval;
     185        errno_t retval;
    186186        async_wait_for(req, &retval);
    187187
     
    205205 * @return       EOK on success or an error code
    206206 */
    207 static int vbd_get_ids_internal(vbd_t *vbd, sysarg_t method, sysarg_t arg1,
     207static errno_t vbd_get_ids_internal(vbd_t *vbd, sysarg_t method, sysarg_t arg1,
    208208    sysarg_t **data, size_t *count)
    209209{
     
    212212
    213213        size_t act_size = 0;
    214         int rc = vbd_get_ids_once(vbd, method, arg1, NULL, 0, &act_size);
     214        errno_t rc = vbd_get_ids_once(vbd, method, arg1, NULL, 0, &act_size);
    215215        if (rc != EOK)
    216216                return rc;
     
    249249 * @return EOK on success or an error code
    250250 */
    251 int vbd_label_get_parts(vbd_t *vbd, service_id_t disk,
     251errno_t vbd_label_get_parts(vbd_t *vbd, service_id_t disk,
    252252    service_id_t **data, size_t *count)
    253253{
     
    256256}
    257257
    258 int vbd_part_get_info(vbd_t *vbd, vbd_part_id_t part, vbd_part_info_t *pinfo)
    259 {
    260         async_exch_t *exch;
    261         int retval;
     258errno_t vbd_part_get_info(vbd_t *vbd, vbd_part_id_t part, vbd_part_info_t *pinfo)
     259{
     260        async_exch_t *exch;
     261        errno_t retval;
    262262        ipc_call_t answer;
    263263
    264264        exch = async_exchange_begin(vbd->sess);
    265265        aid_t req = async_send_1(exch, VBD_PART_GET_INFO, part, &answer);
    266         int rc = async_data_read_start(exch, pinfo, sizeof(vbd_part_info_t));
    267         async_exchange_end(exch);
    268 
    269         if (rc != EOK) {
    270                 async_forget(req);
    271                 return EIO;
    272         }
    273 
    274         async_wait_for(req, &retval);
    275         if (retval != EOK)
    276                 return EIO;
    277 
    278         return EOK;
    279 }
    280 
    281 int vbd_part_create(vbd_t *vbd, service_id_t disk, vbd_part_spec_t *pspec,
     266        errno_t rc = async_data_read_start(exch, pinfo, sizeof(vbd_part_info_t));
     267        async_exchange_end(exch);
     268
     269        if (rc != EOK) {
     270                async_forget(req);
     271                return EIO;
     272        }
     273
     274        async_wait_for(req, &retval);
     275        if (retval != EOK)
     276                return EIO;
     277
     278        return EOK;
     279}
     280
     281errno_t vbd_part_create(vbd_t *vbd, service_id_t disk, vbd_part_spec_t *pspec,
    282282    vbd_part_id_t *rpart)
    283283{
    284284        async_exch_t *exch;
    285         int retval;
     285        errno_t retval;
    286286        ipc_call_t answer;
    287287
    288288        exch = async_exchange_begin(vbd->sess);
    289289        aid_t req = async_send_1(exch, VBD_PART_CREATE, disk, &answer);
    290         int rc = async_data_write_start(exch, pspec, sizeof(vbd_part_spec_t));
     290        errno_t rc = async_data_write_start(exch, pspec, sizeof(vbd_part_spec_t));
    291291        async_exchange_end(exch);
    292292
     
    305305}
    306306
    307 int vbd_part_delete(vbd_t *vbd, vbd_part_id_t part)
    308 {
    309         async_exch_t *exch;
    310         int retval;
     307errno_t vbd_part_delete(vbd_t *vbd, vbd_part_id_t part)
     308{
     309        async_exch_t *exch;
     310        errno_t retval;
    311311
    312312        exch = async_exchange_begin(vbd->sess);
     
    334334 * @return EOK on success or an error code
    335335 */
    336 int vbd_suggest_ptype(vbd_t *vbd, service_id_t disk, label_pcnt_t pcnt,
     336errno_t vbd_suggest_ptype(vbd_t *vbd, service_id_t disk, label_pcnt_t pcnt,
    337337    label_ptype_t *ptype)
    338338{
    339339        async_exch_t *exch;
    340         int retval;
     340        errno_t retval;
    341341        ipc_call_t answer;
    342342
    343343        exch = async_exchange_begin(vbd->sess);
    344344        aid_t req = async_send_2(exch, VBD_SUGGEST_PTYPE, disk, pcnt, &answer);
    345         int rc = async_data_read_start(exch, ptype, sizeof(label_ptype_t));
     345        errno_t rc = async_data_read_start(exch, ptype, sizeof(label_ptype_t));
    346346        async_exchange_end(exch);
    347347
Note: See TracChangeset for help on using the changeset viewer.