What not to be doing - syscall()

Thiago Macieira thiago.macieira at kdemail.net
Wed Dec 24 05:08:20 GMT 2003


Daniel Stone wrote:
>This is a pretty good example of what *not* to do. syscall() is not
>portable across architectures (it caused a recent FTBFS[1] on
>mips/mipsel for Debian packages). To do this, use sysinfo(&info)
>instead.

Hello,

your changes introduced a new FTBFS in kdeutils/ksim/systeminfo.cpp. The 
following patch causes this:

 {
 #ifdef __linux__
   sysinfo system;
-  if (syscall(SYS_sysinfo, &system) < 0) {
-    fprintf(stderr, "Error calling syscall()\n");
+  if (sysinfo(&system) < 0) {
+    fprintf(stderr, "Error calling sysinfo()\n");
     return;
   }

The construct is obviously wrong because "sysinfo" cannot be at the same time 
a type identifier and a function. Prefixing the type identifier with "struct" 
fixes the problem.

I am attaching the patch I have committed to CVS.
-- 
  Thiago Macieira  -  Registered Linux user #65028
   thiagom (AT) mail (dot) com
    ICQ UIN: 1967141   PGP/GPG: 0x6EF45358; fingerprint:
    E067 918B B660 DBD1 105C  966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ksim-systeminfo.diff
Type: text/x-diff
Size: 547 bytes
Desc: not available
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20031224/e77f4dcd/attachment.diff>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: signature
URL: <http://mail.kde.org/pipermail/kde-core-devel/attachments/20031224/e77f4dcd/attachment.sig>


More information about the kde-core-devel mailing list