Page MenuHomeFreeBSD

Apply some style(9) and fix some CLANG warnings.
ClosedPublic

Authored by araujo on May 29 2015, 9:43 AM.
Tags
None
Referenced Files
Unknown Object (File)
Apr 26 2024, 6:38 AM
Unknown Object (File)
Apr 26 2024, 6:23 AM
Unknown Object (File)
Jan 1 2024, 7:05 AM
Unknown Object (File)
Dec 20 2023, 7:50 AM
Unknown Object (File)
Jul 28 2023, 6:42 AM
Unknown Object (File)
Jul 4 2023, 12:54 AM
Unknown Object (File)
Jun 16 2023, 5:03 AM
Unknown Object (File)
May 21 2023, 9:30 PM
Subscribers

Details

Summary
  • Set signaled, errflg and rmverbose as static, it is used only inside the ipcrm.c.
  • Clean up some extra NEW BLANK LINES.
  • Extern some fucntions such like semctl, semget and so on.
  • Reorder the parameters of semctl.
  • Usage() don't need to use exit(1) as it is a void function with no return.

Diff Detail

Repository
rS FreeBSD src repository - subversion
Lint
Lint Not Applicable
Unit
Tests Not Applicable

Event Timeline

araujo retitled this revision from to Apply some style(9) and fix some CLANG warnings..
araujo updated this object.
araujo edited the test plan for this revision. (Show Details)
usr.bin/ipcs/ipc.h
70 ↗(On Diff #5771)

Instead of putting these prototypes here, would. it be possible to instead put this in the .c files:

#include <sys/types.h>

#include <sys/ipc.h>
#include <sys/msg.h>
#include <sys/sem.h>

as specified in the semget() and msgget() man pages?

Other than that, this patch looks OK.

rodrigc@: Do you mean like this? Yes it is possible!!

usr.bin/ipcrm/ipcrm.c
63 ↗(On Diff #5772)

Why do you need these prototypes here at all? Why not include the necessary header
files as I specified in my previous review comment?

usr.bin/ipcrm/ipcrm.c
63 ↗(On Diff #5772)

Because there is a macro _KERNEL to control the visibility of types and prototypes in system headers, specifically for sem.h, shm.h and msg.h.

Even include directly the headers as you mention, the prototypes are still not visible and CLANG will report the same warnings, plus some more.

usr.bin/ipcrm/ipcrm.c
63 ↗(On Diff #5772)

Oh, I see, thanks for the explanation.
This is ugly stuff. :(

Instead of copying the prototypes to the .c file though,
What I would recommend doing is this:

(1) Modify the src/sys/sys/sem.h header file with this:

Index: sys/sys/sem.h

  • sys/sys/sem.h (revision 283641)

+++ sys/sys/sem.h (working copy)
@@ -137,8 +137,9 @@

*/

void semexit(struct proc *p);

-#else /* ! _KERNEL */
+#endif /* _KERNEL */

+if !defined(_KERNEL) || defined(_WANT_SEM_PROTOTYPES)
BEGIN_DECLS
#if
BSD_VISIBLE
int semsys(int, ...);

Then in the .c file,

#define _WANT_SEM_PROTOTYPES
#define _KERNEL
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#undef _KERNEL
usr.bin/ipcrm/ipcrm.c
63 ↗(On Diff #5772)

Oh, I see, thanks for the explanation.
This is ugly stuff. :(

Instead of copying the prototypes to the .c file though,
What I would recommend doing is this:

(1) Modify the src/sys/sys/sem.h header file with this:

Index: sys/sys/sem.h
===================================================================
--- sys/sys/sem.h       (revision 283641)
+++ sys/sys/sem.h       (working copy)
@@ -137,8 +137,9 @@
  */
 void   semexit(struct proc *p);
 
-#else /* ! _KERNEL */
+#endif /* _KERNEL */
 
+if !defined(_KERNEL) || defined(_WANT_SEM_PROTOTYPES)
 __BEGIN_DECLS
 #if __BSD_VISIBLE
 int semsys(int, ...);

Then in the .c file,

#define _WANT_SEM_PROTOTYPES
#define _KERNEL
#include <sys/sem.h>
#include <sys/shm.h>
#include <sys/msg.h>
#undef _KERNEL

This patch is what I had in mind: