Thread: Negative Return Problem

  1. #1
    Registered User
    Join Date
    Mar 2012

    Negative Return Problem

    i Have a Function,whose basic structure is
     signed char fun()
    signed char a;
    return a;
    now when i run this code on Coverity tool, i'm getting error as negative return

    what can be done to solve this thing?

    P.S : please mind that the code i shared is a basic one,
    it has lot of dependenies in the program
    Last edited by manju1438; 03-29-2012 at 08:19 AM.

  2. #2
    Technical Lead QuantumPete's Avatar
    Join Date
    Aug 2007
    London, UK
    Are you assigning the return value of your function to an unsigned int, perhaps?
    "No-one else has reported this problem, you're either crazy or a liar" - Dogbert Technical Support
    "Have you tried turning it off and on again?" - The IT Crowd

  3. #3
    Registered User
    Join Date
    Mar 2011
    doesn't that warning mean you are using the return value to index an array?

    "In particular, Coverity Prevent™ currently detects several types of buffer
    overruns in the heap and the stack. Those results marked as "Negative
    Returns" and "Reverse Negative"

  4. #4
    Registered User
    Join Date
    Dec 2011
    To tell if your function or your usage of said function is at fault:

    printf("%d", fun());

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 8
    Last Post: 10-11-2011, 06:42 PM
  2. problem with return value in C
    By jericjones45 in forum C Programming
    Replies: 8
    Last Post: 03-27-2010, 05:17 PM
  3. unsigned negative problem :s
    By nas_am in forum C++ Programming
    Replies: 1
    Last Post: 04-01-2009, 07:35 AM
  4. Problem with return
    By -Prime- in forum C Programming
    Replies: 4
    Last Post: 10-10-2006, 02:52 PM
  5. return problem
    By peterx in forum C Programming
    Replies: 3
    Last Post: 10-09-2005, 07:47 AM

Tags for this Thread