Changeset a35b458 in mainline for uspace/lib/posix/src/stdio.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/lib/posix/src/stdio.c

    r3061bc1 ra35b458  
    277277        size_t sz;
    278278        char buf[4];
    279        
     279
    280280        while (offset < size) {
    281281                sz = 0;
     
    283283                        break;
    284284                }
    285                
     285
    286286                const int fildes = *(int *) fd;
    287287                size_t nwr;
    288288                if (vfs_write(fildes, &posix_pos[fildes], buf, sz, &nwr) != EOK)
    289289                        break;
    290                
     290
    291291                chars++;
    292292                offset += sizeof(wchar_t);
    293293        }
    294        
     294
    295295        return chars;
    296296}
     
    311311                .data = &fildes
    312312        };
    313        
     313
    314314        return printf_core(format, &spec, ap);
    315315}
     
    490490{
    491491        assert(L_tmpnam >= strlen("/tmp/tnXXXXXX"));
    492        
     492
    493493        static char buffer[L_tmpnam + 1];
    494494        if (s == NULL) {
    495495                s = buffer;
    496496        }
    497        
     497
    498498        strcpy(s, "/tmp/tnXXXXXX");
    499499        mktemp(s);
    500        
     500
    501501        if (*s == '\0') {
    502502                /* Errno set by mktemp(). */
    503503                return NULL;
    504504        }
    505        
     505
    506506        return s;
    507507}
     
    518518        /* Sequence number of the filename. */
    519519        static int seq = 0;
    520        
     520
    521521        size_t dir_len = strlen(dir);
    522522        if (dir[dir_len - 1] == '/') {
    523523                dir_len--;
    524524        }
    525        
     525
    526526        size_t pfx_len = strlen(pfx);
    527527        if (pfx_len > 5) {
    528528                pfx_len = 5;
    529529        }
    530        
     530
    531531        char *result = malloc(dir_len + /* slash*/ 1 +
    532532            pfx_len + /* three-digit seq */ 3 + /* .tmp */ 4 + /* nul */ 1);
    533        
     533
    534534        if (result == NULL) {
    535535                errno = ENOMEM;
    536536                return NULL;
    537537        }
    538        
     538
    539539        char *res_ptr = result;
    540540        strncpy(res_ptr, dir, dir_len);
     
    542542        strncpy(res_ptr, pfx, pfx_len);
    543543        res_ptr += pfx_len;
    544        
     544
    545545        for (; seq < 1000; ++seq) {
    546546                snprintf(res_ptr, 8, "%03d.tmp", seq);
    547                
     547
    548548                int orig_errno = errno;
    549549                errno = EOK;
     
    559559                }
    560560        }
    561        
     561
    562562        if (seq == 1000) {
    563563                free(result);
     
    565565                return NULL;
    566566        }
    567        
     567
    568568        return result;
    569569}
     
    585585                return NULL;
    586586        }
    587        
     587
    588588        /* Unlink the created file, so that it's removed on close(). */
    589589        unlink(filename);
Note: See TracChangeset for help on using the changeset viewer.