Changeset 7c2a3c7 in mainline for uspace/app/cmpdirs/cmpdirs.c


Ignore:
Timestamp:
2026-03-17T12:37:05Z (31 hours ago)
Author:
Vít Skalický <skalicky@…>
Children:
df4f7c30
Parents:
4a998bf9
git-author:
Vít Skalický <skalicky@…> (2026-03-16 13:48:05)
git-committer:
Vít Skalický <skalicky@…> (2026-03-17 12:37:05)
Message:

Improve comments

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/cmpdirs/cmpdirs.c

    r4a998bf9 r7c2a3c7  
    5454#define NAME_BUFFER_SIZE 256
    5555
    56 // Macros to make handling error less clumbersome
     56// Macros to make handling errors less cumbersome
    5757#define _check_ok(rc, action, ...) if ((rc) != EOK) {fprintf(stderr, __VA_ARGS__); log_msg(LOG_DEFAULT, LVL_ERROR, __VA_ARGS__ ); action; }
     58/** Print message (given by the variable arguments) to log and stderr if rc != EOK and then goto the specified label. */
    5859#define check_ok(rc, label, ...) _check_ok(rc, goto label, __VA_ARGS__)
     60/** Print message (given by the variable arguments) to log and stderr if rc != EOK and then break. */
    5961#define check_ok_break(rc, ...) _check_ok(rc, break, __VA_ARGS__)
    6062
     
    139141}
    140142
     143/** Handles of 2 files or directories to compare */
    141144struct entry {
    142145        int handle1;
     
    156159size_t STACK_INIT_CAPACITY = 256;
    157160
    158 /** Create a new growable stack. Don't forget to free it in the end using stack_free */
     161/** Create a new growable stack. Don't forget to free it using stack_free when you are done using it. */
    159162static errno_t stack_new(struct stack* s) {
    160163        s->size = 0;
     
    201204}
    202205
    203 /** Returns the last entry in the stack and removes it from it. Does not free any memory */
     206/** Returns the last entry in the stack and removes it from it. Does not free any memory. */
    204207static errno_t stack_pop(struct stack *s, struct entry *entry_out) {
    205208        if (s->size == 0) {
     
    231234}
    232235
    233 /** Compares the contetn of 2 files. It assumes:
     236/** Compares the content of 2 files. It assumes:
    234237 *  - both handles represent a file, not dir
    235238 *  - both files have the same size
    236239 *  - both buffers are the size CHUNK_SIZE
    237  *  - both handle are open for reading */
     240 *  - both handles are open for reading */
    238241static errno_t content_equal(int handle1, vfs_stat_t stat1, char* buffer1, int handle2, vfs_stat_t stat2, char* buffer2, bool *equal_out) {
    239242        errno_t rc = EOK;
     
    265268}
    266269
    267 /** Checks if the directory/file tree of both handles is equal -- checks presence of files/dirs, content of all files, and metadata. */
    268270static errno_t trees_equal(int root_handle1, int root_handle2, bool* equal_out) {
    269         // todo don't forget to check put/close all file handles
     271        // todo Check once again that all file handles are put at the end
    270272        // Performs a depth-first search on handle1 and compares it to handle2.
    271273        errno_t rc = EOK;
     
    289291
    290292        char name_buffer[NAME_BUFFER_SIZE];
    291 
    292         // no need to add the initial entry into stack - it's the initial value in the for cycle
    293         // rc = stack_append(&s, (struct entry){handle1, handle2});
    294         // if (rc != EOK) goto close3;
    295293
    296294        // While there is something in the stack
Note: See TracChangeset for help on using the changeset viewer.