Changeset b7be230 in mainline


Ignore:
Timestamp:
2009-01-22T17:11:54Z (15 years ago)
Author:
Tim Post <echo@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
bffd91f
Parents:
bf226890
Message:

Stop using assert() in modules/builtins as abort() will crash the entire shell.
Handle the case and report the issue, leaving the user able to reproduce it
without rebooting.

Location:
uspace/app/bdsh/cmds/modules
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/app/bdsh/cmds/modules/cp/cp.c

    rbf226890 rb7be230  
    3535#include <string.h>
    3636#include <fcntl.h>
    37 #include <assert.h>
    3837#include "config.h"
    3938#include "util.h"
     
    125124                        res -= bytes;
    126125                } while (res > 0);
    127                 assert(res == 0);
     126
     127                /* TODO: re-insert assert() once this is stand alone,
     128                 * removed as abort() exits the entire shell
     129                 */
     130                if (res != 0) {
     131                        printf("\n%d more bytes than actually exist were copied\n", res);
     132                        goto err;
     133                }
    128134        }
    129135
    130136        if (bytes < 0) {
    131137err:
    132                 printf("Error copying %s, (%d)\n", src, bytes);
     138                printf("\nError copying %s, (%d)\n", src, bytes);
    133139                copied = bytes;
    134140        }
  • uspace/app/bdsh/cmds/modules/rm/rm.c

    rbf226890 rb7be230  
    3434#include <fcntl.h>
    3535#include <dirent.h>
    36 #include <assert.h>
    3736#include <getopt.h>
    3837
     
    220219                len = strlen(argv[i]) + 2;
    221220                buff = (char *) realloc(buff, len);
    222                 assert(buff != NULL);
     221                if (buff == NULL) {
     222                        printf("rm: out of memory\n");
     223                        ret = 1;
     224                        break;
     225                }
    223226                memset(buff, 0, sizeof(buff));
    224227                snprintf(buff, len, argv[i]);
Note: See TracChangeset for help on using the changeset viewer.