ViewVC Help
View File | Revision Log | Show Annotations | View Changeset | Root Listing
root/svn/ircd-hybrid/trunk/src/conf_db.c
(Generate patch)

Comparing ircd-hybrid/trunk/src/conf_db.c (file contents):
Revision 1620 by michael, Wed Oct 31 22:54:58 2012 UTC vs.
Revision 1621 by michael, Wed Oct 31 23:11:40 2012 UTC

# Line 41 | Line 41
41   * \param f dbFile Struct Member
42   * \return int 0 if failure, 1 > is the version number
43   */
44 < int
44 > uint32_t
45   get_file_version(struct dbFILE *f)
46   {
47 <  FILE *fp = f->fp;
48 <  int version = fgetc(fp) << 24 | fgetc(fp) << 16 | fgetc(fp) << 8 | fgetc(fp);
47 >  uint32_t version = 0;
48  
49 <  if (ferror(fp))
49 >  if (read_uint32(&version, f) == -1)
50    {
51 <    ilog(LOG_TYPE_IRCD, "Error reading version number on %s", f->filename);
51 >    ilog(LOG_TYPE_IRCD, "Error reading version number on %s: %s",
52 >         f->filename, strerror(errno));
53      return 0;
54    }
55 <  else if (feof(fp))
56 <  {
57 <    ilog(LOG_TYPE_IRCD, "Error reading version number on %s: End of file detected",
58 <         f->filename);
59 <    return 0;
60 <  }
61 <  else if (version < 1)
55 >
56 >  if (version < 1)
57    {
58 <    ilog(LOG_TYPE_IRCD, "Invalid version number (%d) on %s",
58 >    ilog(LOG_TYPE_IRCD, "Invalid version number (%u) on %s",
59           version, f->filename);
60      return 0;
61    }

Diff Legend

Removed lines
+ Added lines
< Changed lines (old)
> Changed lines (new)