Changeset 5fca55f for util.c


Ignore:
Timestamp:
Nov 19, 2010, 2:15:34 AM (10 years ago)
Author:
Karl Ramm <kcr@1ts.org>
Branches:
master, release-1.7, release-1.8, release-1.9
Children:
950e2da
Parents:
b401ef2
git-author:
Jason Gross <jgross@MIT.EDU> (11/17/10 02:18:47)
git-committer:
Karl Ramm <kcr@1ts.org> (11/19/10 02:15:34)
Message:
I/O errors on writing subscription file in :unsub are no longer clobbered by "No subscription present in..."

owl_util_file_deleteline now returns -1 on error, and owl_zephyr_delsub
now checks linesdeleted == 0 before erroring with "No subscription
present in...".

Additionally, free(filename) corrected to owl_free(filename) in two
places.

Reviewed-By: Karl Ramm <kcr@1ts.org>
File:
1 edited

Legend:

Unmodified
Added
Removed
  • util.c

    rc1f1e1e r5fca55f  
    381381 * case-insensitive.
    382382 *
    383  * Returns the number of lines removed
     383 * Returns the number of lines removed on success.  Returns -1 on failure.
    384384 */
    385385int owl_util_file_deleteline(const char *filename, const char *line, int backup)
     
    393393    owl_function_error("Cannot open %s (for reading): %s",
    394394                       filename, strerror(errno));
    395     return 0;
     395    return -1;
    396396  }
    397397
    398398  if (fstat(fileno(old), &st) != 0) {
    399399    owl_function_error("Cannot stat %s: %s", filename, strerror(errno));
    400     return 0;
     400    return -1;
    401401  }
    402402
     
    405405    owl_function_error("Cannot open %s (for writing): %s",
    406406                       filename, strerror(errno));
    407     free(newfile);
     407    owl_free(newfile);
    408408    fclose(old);
    409     return 0;
     409    return -1;
    410410  }
    411411
     
    415415    unlink(newfile);
    416416    fclose(new);
    417     free(newfile);
     417    owl_free(newfile);
    418418    fclose(old);
    419     return 0;
     419    return -1;
    420420  }
    421421
     
    438438      unlink(newfile);
    439439      owl_free(newfile);
    440       return 0;
     440      return -1;
    441441    }
    442442    owl_free(backupfile);
     
    446446    owl_function_error("Cannot move %s to %s: %s",
    447447                       newfile, filename, strerror(errno));
    448     numremoved = 0;
     448    numremoved = -1;
    449449  }
    450450
Note: See TracChangeset for help on using the changeset viewer.