<html lang='en'>
<head>
<meta content='text/html; charset=utf-8' http-equiv='Content-Type'>
<title>
GitLab
</title>
</meta>
</head>
<style>
  img {
    max-width: 100%;
    height: auto;
  }
  p.details {
    font-style:italic;
    color:#777
  }
  .footer p {
    font-size:small;
    color:#777
  }
  pre.commit-message {
    white-space: pre-wrap;
  }
  .file-stats a {
    text-decoration: none;
  }
  .file-stats .new-file {
    color: #090;
  }
  .file-stats .deleted-file {
    color: #B00;
  }
</style>
<body>
<div class='content'>
<h3>Andrew Price pushed to branch master at <a href="https://projects.sucs.org/arthur/mw">Justin Mitchell / mw</a></h3>
<h4>
Commits:
</h4>
<ul>
<li>
<strong><a href="https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f">ff58d063</a></strong>
<div>
<span>by Andrew Price</span>
<i>at 2016-01-20T21:02:50Z</i>
</div>
<pre class='commit-message'>Fix up create_folder_file

Use ftruncate instead of writing malloced garbage entries to set the
file size of folders.bb, which dictates the (seemingly arbitrary) 64
folder limit. Also make it return on error instead of exiting.</pre>
</li>
</ul>
<h4>3 changed files:</h4>
<ul>
<li class='file-stats'>
<a href='#diff-0'>
src/client/folders.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-1'>
src/folders.c
</a>
</li>
<li class='file-stats'>
<a href='#diff-2'>
src/folders.h
</a>
</li>
</ul>
<h4>Changes:</h4>
<li id='diff-0'>
<a href='https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f#diff-0'>
<strong>
src/client/folders.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/client/folders.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/client/folders.c
</span><span style="color: #aaaaaa">@@ -25,7 +25,8 @@ void add_folder(void)
</span>   int folnum = -1;
        char tmp[11];
 
<span style="color: #000000;background-color: #ffdddd">-        if (nofolders()) create_folder_file();
</span><span style="color: #000000;background-color: #ddffdd">+   if (nofolders() && create_folder_file())
+               exit(1);
</span>   file=openfolderfile(O_RDWR);
        do{
                yes=get_folder_entry(file, &new);
</code></pre>

<br>
</li>
<li id='diff-1'>
<a href='https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f#diff-1'>
<strong>
src/folders.c
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/folders.c
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/folders.c
</span><span style="color: #aaaaaa">@@ -50,24 +50,23 @@ int nofolders(void)
</span>   return 0;
 }
 
<span style="color: #000000;background-color: #ffdddd">-void create_folder_file(void)
</span><span style="color: #000000;background-color: #ddffdd">+int create_folder_file(void)
</span> {
<span style="color: #000000;background-color: #ffdddd">-        int file,i;
-       struct folder *record;
</span><span style="color: #000000;background-color: #ddffdd">+   int file;
+       int ret;
</span> 
<span style="color: #000000;background-color: #ffdddd">-        record=(struct folder *)malloc(sizeof(*record));
-       record->status=0;
-       file=open(FOLDERFILE,O_WRONLY|O_CREAT,0600);
</span><span style="color: #000000;background-color: #ddffdd">+   file = open(FOLDERFILE, O_WRONLY|O_CREAT, 0600);
+       if (file < 0) {
+               perror(FOLDERFILE);
+               return 1;
+       }
</span>   Lock_File(file);
<span style="color: #000000;background-color: #ffdddd">-        for (i=0;i<64;i++)
-               if (write(file,record,sizeof(*record))<0)
-               {
-                       perror("creating blank folders");
-                       exit(-1);
-               }
</span><span style="color: #000000;background-color: #ddffdd">+   ret = ftruncate(file, sizeof(struct folder) * 64);
+       if (ret != 0)
+               perror("Truncating folder file");
</span>   Unlock_File(file);
        close(file);
<span style="color: #000000;background-color: #ffdddd">-        free(record);
</span><span style="color: #000000;background-color: #ddffdd">+   return ret;
</span> }
 
 int foldernumber(const char *name)
</code></pre>

<br>
</li>
<li id='diff-2'>
<a href='https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f#diff-2'>
<strong>
src/folders.h
</strong>
</a>
<hr>
<pre class="highlight"><code><span style="color: #000000;background-color: #ffdddd">--- a/src/folders.h
</span><span style="color: #000000;background-color: #ddffdd">+++ b/src/folders.h
</span><span style="color: #aaaaaa">@@ -60,7 +60,7 @@ extern const char *folder_types[4];
</span> 
 int openfolderfile(int mode);
 int nofolders(void);
<span style="color: #000000;background-color: #ffdddd">-void create_folder_file(void);
</span><span style="color: #000000;background-color: #ddffdd">+int create_folder_file(void);
</span> int foldernumber(const char *name);
 int get_folder_entry(int file, struct folder *tmp);
 int get_folder_number(struct folder *fol, int num);
</code></pre>

<br>
</li>

</div>
<div class='footer' style='margin-top: 10px;'>
<p>

<br>
<a href="https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f">View it on GitLab</a>.
<br>
You're receiving this email because of your account on projects.sucs.org.
If you'd like to receive fewer emails, you can adjust your notification settings.
<script type="application/ld+json">{"@context":"http://schema.org","@type":"EmailMessage","action":{"@type":"ViewAction","name":"View Commit","url":"https://projects.sucs.org/arthur/mw/commit/ff58d063d9420bdef62faa1128e037e295eb737f"}}</script>
</p>
</div>
</body>
</html>