473,703 Members | 3,036 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

error:return makes integer from pointer without a cast

6 New Member
error:return makes integer from pointer without a cast..
following is my code ..plz help to track the bug

Expand|Select|Wrap|Line Numbers
  1. .........
Expand|Select|Wrap|Line Numbers
  1.  
  2. #include <stdio.h>
  3. #include <stdlib.h>
  4. #include <sys/stat.h>
  5. #include <usb.h>
  6. struct usb_device *tusb_dev1,*tusb_dev2 = NULL;
  7. int x;
  8.  
  9. int usb_found(struct usb_device *dev)
  10. {
  11. struct usb_device *tusb_dev1,*tusb_dev2;
  12. struct usb_dev_handle *tusb;
  13.  
  14.         if(x==1)
  15.         {
  16.             tusb_dev1=dev;
  17.  
  18.             printf("\nDevice 3210 found\n");
  19.  
  20.             printf("\ntusb_dev1 %d  \n",tusb_dev1);
  21.  
  22.             if(tusb_dev1==NULL)
  23.             {
  24.             printf("\ntusb_dev1 is null \n");
  25.             return;
  26.             }
  27.             if((tusb=usb_open(tusb_dev1))==NULL)
  28.              {
  29.             printf("Error opening 3210 USB device.\n");
  30.             return 1;
  31.             }
  32.  
  33.             printf("\n (Setting Configuration ........)\n");
  34.  
  35.             if(usb_set_configuration(tusb, 1))
  36.             {
  37.                   perror("\n Can't set configuration");
  38.                     printf("\n (make sure you have write access to the device)\n");
  39.             x=2;
  40.             usb_found(dev);
  41.             return;
  42.             }
  43.         }
  44.         else if(x==2)
  45.         {
  46.             tusb_dev2=dev;
  47.  
  48.             printf("\nDevice 3211 found\n");
  49.  
  50.             printf("\ntusb_dev2 %d  \n",tusb_dev2);
  51.  
  52.             if(tusb_dev2==NULL)
  53.             {
  54.             printf("\n tusb_dev2 is null\n");
  55.             return;
  56.             }
  57.             if((tusb=usb_open(tusb_dev2))==NULL)
  58.              {
  59.             printf("Error opening 3210 USB device.\n");
  60.             return 1;
  61.             }
  62.  
  63.             printf("\n (Setting Configuration ........)\n");
  64.  
  65.             if(usb_set_configuration(tusb, 1))
  66.             {
  67.                   perror("\n Can't set configuration");
  68.                     printf("\n (make sure you have write access to the device)\n");
  69.             x=1;
  70.             usb_found(dev);
  71.             return;
  72.             }
  73.         }    
  74.  
  75.     printf("\n (Claiming Interface for .......)\n");
  76.     usb_claim_interface(tusb, 0);
  77.     printf("\n out of usb_3210 function\n");
  78.     return(tusb); //(interface);
  79.  
  80. }
  81.  
  82. int  main(void)
  83.     {
  84.     struct usb_bus *bus;
  85.     struct usb_device *dev;
  86.     struct usb_device *tusb_dev1,*tusb_dev2 = NULL;
  87.     struct usb_dev_handle *tusb = NULL;
  88.     int device_found,dev_num,no_of_devices;
  89.     char ans;
  90.  
  91.     usb_init();
  92.     usb_find_busses();
  93.     usb_find_devices();
  94.  
  95.     for (bus = usb_busses; bus; bus = bus->next) {
  96.     for (dev = bus->devices; dev; dev = dev->next) {
  97.     if(dev->descriptor.idVendor==0x0451 && dev->descriptor.idProduct==0x3210) 
  98.     {
  99.         tusb_dev1=dev;
  100.         printf("\ntusb_dev1 %d\n", tusb_dev1);
  101.         device_found =1;
  102.  
  103.     }
  104.     else if(dev->descriptor.idVendor==0x0451 && dev->descriptor.idProduct==0x3211) 
  105.     {
  106.         tusb_dev2=dev;
  107.         printf("\ntusb_dev2 %d  \n",tusb_dev2);
  108.         device_found =2;
  109.  
  110.     }
  111.  
  112.     }
  113.  
  114.     }
  115.  
  116.     if(device_found>=3)
  117.     {
  118.     printf("\nMore than 2 devices\n");
  119.     return;
  120.     }
  121.     else if(device_found ==0)
  122.                {
  123.                 printf("\nNo device found\n");
  124.                     return -1;
  125.                    }
  126.  
  127.  
  128.  
  129.  
  130.  
  131. for (bus = usb_busses; bus; bus = bus->next) {
  132.     for (dev = bus->devices; dev; dev = dev->next) {
  133.  
  134.  if(dev->descriptor.idVendor==0x0451 && dev->descriptor.idProduct==0x3210 && device_found==1) 
  135.     {    
  136.         x=1;
  137.         usb_found(dev);
  138.  
  139.          }
  140.     else if(dev->descriptor.idVendor==0x0451 && dev->descriptor.idProduct==0x3211 && device_found==2)
  141.     {
  142.         x=2;
  143.         usb_found(dev);
  144.     } 
  145.     }
  146.     }
  147.  
  148.     do
  149.     {
  150.         printf("\n Wish to continue??\n");
  151.             ans=getchar();
  152.     }
  153.     while(ans =='y'|| ans =='Y');
  154.  
  155.     if(tusb!=NULL)
  156.     {
  157.          usb_close(tusb);
  158.     }
  159.     return;
  160.     }
  161.  
Oct 18 '08 #1
1 5855
JosAH
11,448 Recognized Expert MVP
In this function with a pointer defined as follows:

Expand|Select|Wrap|Line Numbers
  1. int usb_found(struct usb_device *dev)
  2. {
  3. struct usb_device *tusb_dev1,*tusb_dev2;
  4. struct usb_dev_handle *tusb;
  5.  
I find the following different return statements:

Expand|Select|Wrap|Line Numbers
  1.             return;
  2.             return 1;
  3.     return(tusb); //(interface);
  4.  
Similar things happen all over the code. It is a mess; if your function returns a
value of type T is should only return things of type T and nothing else.

kind regards,

Jos
Oct 18 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
4356
by: David Girard | last post by:
I'm getting the following error which is no big deal - the problem is it is LOCATION specific - which has me really baffled... for some reason the error only appears on different machines in different various locations. I've checked the versions of browsers and I've tried from at least 10 different pc's in different locations and the page comes up perfect. My web server is up to date with all current patches. Occasionally, someone will...
5
5027
by: Chumley the Walrus | last post by:
When i put an explicit value in the sql statement below as "displaygroup =1 ", i do see my records (or my response.write test after the recordset Open line) appear on my dynamic page. But when use code below and match the 'displaygroup' field with my dp variable (which was assigned in a prior recordset/sql block) : <%dim cm,dp dp = rs("displaygroup")
4
3049
by: ben | last post by:
why is it, in the below code, when there's a printf statement (the one commented with /* ****** */) the final for loop prints out fine, but without the commented with stars printf statement included in the code there's a bus error on the fourth element in the final for loop? final for loop print out when the /* ****** */ printf line is included in the code: ab ba
6
3548
by: Kinbote | last post by:
Hi, I'm trying to make a function that opens a file, reads it in line by line, puts each line into an malloc'd array, and returns the array. I suspect I'm going about it in an atypical fashion, as I'm avoiding the use of fscanf and fgets to read in lines. I don't want to have to specify a temporary char* buffer to read in each line, and then have to concern myself with the (remote) possibility of overflows or with increasing the buffer...
1
1558
by: mabubakarpk | last post by:
HI I want to connect with MS Access 97 with OLEB connection "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=E:\Emp.mdb;Persist Security Info=true" but error return
3
14771
by: Will McGugan | last post by:
Hi, Can anyone suggest a likely cause for the following exception... Exception exceptions.SystemError: 'error return without exception set' in <generator object at 0x0345CF30ignored Thanks Will McGugan
1
11733
by: eros | last post by:
CREATE OR REPLACE FUNCTION f_customerlogininfo(varchar, varchar, varchar) RETURNS public.v_customerlogininfo AS ' DECLARE p_schm ALIAS FOR $1; p_contact ALIAS FOR $2; p_status ALIAS FOR $3; v_boolstatus boolean; BEGIN IF p_status = ''all'' THEN RETURN (select * from v_customerlogininfo where contact = p_contact); ELSE
6
1740
by: sara | last post by:
Hi - I have the code below and it errors with "Type Mismatch" on the last line. I have no idea why. The query is based on one table. Table has 2 fields: Key (autonum) and PONumber (Long) Query has one field -run off the table: PONum.
2
10440
by: globomike | last post by:
Hi, can anybody tell me what the reason code 18 means in combination with a SQL0902 error? It would be helpful to know details about the reason code but I could not find any details about that code. Here is the full error message (out of a DataStage job) E_STG_CRM_PROFILE..xfm3: SQL0902C A system error
0
8759
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8670
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9252
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9017
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6588
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5922
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4433
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3125
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2070
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.