Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 5 additions & 4 deletions client.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include <fcntl.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand All @@ -9,7 +10,7 @@

int main()
{
long long sz;
ssize_t sz;

char buf[1];
char write_buf[] = "testing writing";
Expand All @@ -23,15 +24,15 @@ int main()

for (int i = 0; i <= offset; i++) {
sz = write(fd, write_buf, strlen(write_buf));
printf("Writing to " FIB_DEV ", returned the sequence %lld\n", sz);
printf("Writing to " FIB_DEV ", returned the sequence %zd\n", sz);
}

for (int i = 0; i <= offset; i++) {
lseek(fd, i, SEEK_SET);
sz = read(fd, buf, 1);
printf("Reading from " FIB_DEV
" at offset %d, returned the sequence "
"%lld.\n",
"%zd.\n",
i, sz);
}

Expand All @@ -40,7 +41,7 @@ int main()
sz = read(fd, buf, 1);
printf("Reading from " FIB_DEV
" at offset %d, returned the sequence "
"%lld.\n",
"%zd.\n",
i, sz);
}

Expand Down
6 changes: 3 additions & 3 deletions fibdrv.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ static int major = 0, minor = 0;
* Return: The k-th Fibonacci number on success, -ENOMEM on memory allocation
* failure.
*/
static long long fib_sequence(long long k)
static uint64_t fib_sequence(uint64_t k)
{
long long *f = kmalloc(sizeof(*f) * (k + 2), GFP_KERNEL);
uint64_t *f = kmalloc(sizeof(*f) * (k + 2), GFP_KERNEL);
if (!f)
return -ENOMEM;

Expand All @@ -46,7 +46,7 @@ static long long fib_sequence(long long k)
f[i] = f[i - 1] + f[i - 2];
}

long long ret = f[k];
uint64_t ret = f[k];

kfree(f);

Expand Down