Changeset b7fd2a0 in mainline for uspace/srv/fs/fat/fat_fat.c


Ignore:
Timestamp:
2018-01-13T03:10:29Z (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:
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.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/fs/fat/fat_fat.c

    r36f0738 rb7fd2a0  
    7373 * @return              EOK on success or an error code.
    7474 */
    75 int
     75errno_t
    7676fat_cluster_walk(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc,
    7777    fat_cluster_t *lastc, uint32_t *numc, uint32_t max_clusters)
     
    8080        fat_cluster_t clst = firstc, clst_last1 = FAT_CLST_LAST1(bs);
    8181        fat_cluster_t clst_bad = FAT_CLST_BAD(bs);
    82         int rc;
     82        errno_t rc;
    8383
    8484        if (firstc == FAT_CLST_RES0) {
     
    123123 * @return              EOK on success or an error code.
    124124 */
    125 int
     125errno_t
    126126fat_block_get(block_t **block, struct fat_bs *bs, fat_node_t *nodep,
    127127    aoff64_t bn, int flags)
     
    130130        fat_cluster_t currc = 0;
    131131        aoff64_t relbn = bn;
    132         int rc;
     132        errno_t rc;
    133133
    134134        if (!nodep->size)
     
    188188 * @return              EOK on success or an error code.
    189189 */
    190 int
     190errno_t
    191191_fat_block_get(block_t **block, fat_bs_t *bs, service_id_t service_id,
    192192    fat_cluster_t fcl, fat_cluster_t *clp, aoff64_t bn, int flags)
     
    195195        uint32_t max_clusters;
    196196        fat_cluster_t c = 0;
    197         int rc;
     197        errno_t rc;
    198198
    199199        /*
     
    237237 * @return              EOK on success or an error code.
    238238 */
    239 int
     239errno_t
    240240fat_fill_gap(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl, aoff64_t pos)
    241241{
    242242        block_t *b;
    243243        aoff64_t o, boundary;
    244         int rc;
     244        errno_t rc;
    245245
    246246        boundary = ROUND_UP(nodep->size, BPS(bs) * SPC(bs));
     
    289289 * @return              EOK or an error code.
    290290 */
    291 static int
     291static errno_t
    292292fat_get_cluster_fat12(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    293293    fat_cluster_t clst, fat_cluster_t *value)
     
    296296        uint16_t byte1, byte2;
    297297        aoff64_t offset;
    298         int rc;
     298        errno_t rc;
    299299
    300300        offset = (clst + clst / 2);
     
    359359 * @return              EOK or an error code.
    360360 */
    361 static int
     361static errno_t
    362362fat_get_cluster_fat16(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    363363    fat_cluster_t clst, fat_cluster_t *value)
     
    365365        block_t *b;
    366366        aoff64_t offset;
    367         int rc;
     367        errno_t rc;
    368368
    369369        offset = (clst * FAT16_CLST_SIZE);
     
    390390 * @return              EOK or an error code.
    391391 */
    392 static int
     392static errno_t
    393393fat_get_cluster_fat32(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    394394    fat_cluster_t clst, fat_cluster_t *value)
     
    396396        block_t *b;
    397397        aoff64_t offset;
    398         int rc;
     398        errno_t rc;
    399399
    400400        offset = (clst * FAT32_CLST_SIZE);
     
    423423 * @return              EOK or an error code.
    424424 */
    425 int
     425errno_t
    426426fat_get_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    427427    fat_cluster_t clst, fat_cluster_t *value)
    428428{
    429         int rc;
     429        errno_t rc;
    430430
    431431        assert(fatno < FATCNT(bs));
     
    451451 * @return              EOK on success or an error code.
    452452 */
    453 static int
     453static errno_t
    454454fat_set_cluster_fat12(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    455455    fat_cluster_t clst, fat_cluster_t value)
     
    458458        aoff64_t offset;
    459459        uint16_t byte1, byte2;
    460         int rc;
     460        errno_t rc;
    461461
    462462        offset = (clst + clst / 2);
     
    539539 * @return              EOK on success or an error code.
    540540 */
    541 static int
     541static errno_t
    542542fat_set_cluster_fat16(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    543543    fat_cluster_t clst, fat_cluster_t value)
     
    545545        block_t *b;
    546546        aoff64_t offset;
    547         int rc;
     547        errno_t rc;
    548548
    549549        offset = (clst * FAT16_CLST_SIZE);
     
    572572 * @return              EOK on success or an error code.
    573573 */
    574 static int
     574static errno_t
    575575fat_set_cluster_fat32(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    576576    fat_cluster_t clst, fat_cluster_t value)
     
    578578        block_t *b;
    579579        aoff64_t offset;
    580         int rc;
     580        errno_t rc;
    581581        fat_cluster_t temp;
    582582
     
    609609 * @return              EOK on success or an error code.
    610610 */
    611 int
     611errno_t
    612612fat_set_cluster(fat_bs_t *bs, service_id_t service_id, unsigned fatno,
    613613    fat_cluster_t clst, fat_cluster_t value)
    614614{
    615         int rc;
     615        errno_t rc;
    616616
    617617        assert(fatno < FATCNT(bs));
     
    636636 * @return              EOK on success or an error code.
    637637 */
    638 int fat_alloc_shadow_clusters(fat_bs_t *bs, service_id_t service_id,
     638errno_t fat_alloc_shadow_clusters(fat_bs_t *bs, service_id_t service_id,
    639639    fat_cluster_t *lifo, unsigned nclsts)
    640640{
     
    642642        unsigned c;
    643643        fat_cluster_t clst_last1 = FAT_CLST_LAST1(bs);
    644         int rc;
     644        errno_t rc;
    645645
    646646        for (fatno = FAT1 + 1; fatno < FATCNT(bs); fatno++) {
     
    673673 * @return              EOK on success, an error code otherwise.
    674674 */
    675 int
     675errno_t
    676676fat_alloc_clusters(fat_bs_t *bs, service_id_t service_id, unsigned nclsts,
    677677    fat_cluster_t *mcl, fat_cluster_t *lcl)
     
    682682        fat_cluster_t value = 0;
    683683        fat_cluster_t clst_last1 = FAT_CLST_LAST1(bs);
    684         int rc = EOK;
     684        errno_t rc = EOK;
    685685
    686686        lifo = (fat_cluster_t *) malloc(nclsts * sizeof(fat_cluster_t));
     
    744744 * @return              EOK on success or an error code.
    745745 */
    746 int
     746errno_t
    747747fat_free_clusters(fat_bs_t *bs, service_id_t service_id, fat_cluster_t firstc)
    748748{
     
    750750        fat_cluster_t nextc = 0;
    751751        fat_cluster_t clst_bad = FAT_CLST_BAD(bs);
    752         int rc;
     752        errno_t rc;
    753753
    754754        /* Mark all clusters in the chain as free in all copies of FAT. */
     
    782782 * @return              EOK on success or an error code.
    783783 */
    784 int fat_append_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl,
     784errno_t fat_append_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t mcl,
    785785    fat_cluster_t lcl)
    786786{
     
    788788        fat_cluster_t lastc = 0;
    789789        uint8_t fatno;
    790         int rc;
     790        errno_t rc;
    791791
    792792        if (nodep->firstc == FAT_CLST_RES0) {
     
    829829 * @return              EOK on success or an error code.
    830830 */
    831 int fat_chop_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lcl)
     831errno_t fat_chop_clusters(fat_bs_t *bs, fat_node_t *nodep, fat_cluster_t lcl)
    832832{
    833833        fat_cluster_t clst_last1 = FAT_CLST_LAST1(bs);
    834         int rc;
     834        errno_t rc;
    835835        service_id_t service_id = nodep->idx->service_id;
    836836
     
    880880}
    881881
    882 int
     882errno_t
    883883fat_zero_cluster(struct fat_bs *bs, service_id_t service_id, fat_cluster_t c)
    884884{
    885885        int i;
    886886        block_t *b;
    887         int rc;
     887        errno_t rc;
    888888
    889889        for (i = 0; i < SPC(bs); i++) {
     
    908908 * does not contain a fat file system.
    909909 */
    910 int fat_sanity_check(fat_bs_t *bs, service_id_t service_id)
     910errno_t fat_sanity_check(fat_bs_t *bs, service_id_t service_id)
    911911{
    912912        fat_cluster_t e0 = 0;
    913913        fat_cluster_t e1 = 0;
    914914        unsigned fat_no;
    915         int rc;
     915        errno_t rc;
    916916
    917917        /* Check number of FATs. */
Note: See TracChangeset for help on using the changeset viewer.