0

I have some (presumably stable) legacy C code that uses POSIX system calls to read binary files. It's nothing more than creat(), read(), and write(). The program doesn't sit close to the metal at all (it loads string data into memory), so it seems wrong that it's using syscalls. I think I can refactor it easily to use more standard functions.

But, given that my code doesn't need to be portable, I can't think of a good reason to rewrite it. Am I missing something, or should I leave the code be?

William
  • 213

1 Answers1

6

Yes, of-course you must get rid of those terrible low-level syscalls. And while you are at it, you should also get rid of that terrible low-level language called C.
<sarcasm off>

On a more serious note and based on the principle of YAGNI, unless you have a clear need to change your use of syscalls to something else, doing it is only a waste of effort.

The primary reason for not using those syscalls is because you would need portability to non-posix systems, but you already stated that that is not the case for you.