Add static to each function to limit visibility

This commit is contained in:
zenon 2018-06-09 12:59:21 +02:00
parent 3f975a0721
commit 61d457dfc8

View File

@ -21,7 +21,7 @@ struct circ_buf *shared;
/** /**
* @details File descriptor for shared memory. * @details File descriptor for shared memory.
*/ */
int shmfd; static int shmfd;
/** /**
* @details Semaphore which counts the used space in the shared memory array. * @details Semaphore which counts the used space in the shared memory array.
@ -68,7 +68,7 @@ static void sig_handler(int signum)
* @param void This function takes no parameters. * @param void This function takes no parameters.
* @return Always non-zero. * @return Always non-zero.
*/ */
void usage(void) static void usage(void)
{ {
fprintf(stderr, "SYNOPSIS\n" fprintf(stderr, "SYNOPSIS\n"
"\tsupervisor\n"); "\tsupervisor\n");
@ -81,7 +81,7 @@ void usage(void)
* @param void This function takes no parameters. * @param void This function takes no parameters.
* @return 0 on success, non-zero on failure. * @return 0 on success, non-zero on failure.
*/ */
void cleanup(void) static void cleanup(void)
{ {
shared->quit = 1; shared->quit = 1;
sem_wait(sUsedSpace); sem_wait(sUsedSpace);
@ -114,7 +114,7 @@ void cleanup(void)
* @param void This function takes no parameters. * @param void This function takes no parameters.
* @return This function has no return value. * @return This function has no return value.
*/ */
void initCircBuf(void) static void initCircBuf(void)
{ {
shared->quit = 0; shared->quit = 0;
for (int i = 0; i < MAX_ITEMS; i++) { for (int i = 0; i < MAX_ITEMS; i++) {
@ -131,7 +131,7 @@ void initCircBuf(void)
* @param sem The semaphore to be decremented. * @param sem The semaphore to be decremented.
* @return 0 on success, non-zero on failure. * @return 0 on success, non-zero on failure.
*/ */
void wait_sem(sem_t *sem) static void wait_sem(sem_t *sem)
{ {
while (sem_wait(sem) == -1) { // interrupted by syscall? while (sem_wait(sem) == -1) { // interrupted by syscall?
if (errno == EINTR) { if (errno == EINTR) {
@ -154,7 +154,7 @@ void wait_sem(sem_t *sem)
* @param sFreeSpace Semaphore which counts the free space. * @param sFreeSpace Semaphore which counts the free space.
* @return This function has no return value. * @return This function has no return value.
*/ */
void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace) static void getSolution(sem_t *sUsedSpace, sem_t *sFreeSpace)
{ {
int solution[MAX_ITEMS]; int solution[MAX_ITEMS];
for (int i = 0; i < MAX_ITEMS; i++) { for (int i = 0; i < MAX_ITEMS; i++) {