Spurious lint warning about assigned variable never used

I'm getting a lint warning "assigned value never used" (and another one "set but not used in function")
that seems to be spurious. Test case included below. Can someone either confirm that this is a bug or explain to me why
this warning is legitimate.
marten 229% cc -V
cc: Sun C 5.9 SunOS_sparc Patch 124867-01 2007/07/12
marten 230% uname -a
SunOS marten.isi.edu 5.10 Generic_127111-11 sun4u sparc SUNW,Sun-Blade-1000 Solaris
marten 231% cat test93.c
static long value;
long get_value (void) {
value++;
return value;
int main (int argc, char ** argv) {
long k, val;
value = 0;
k = 0;
while ((val = get_value()) != 47) {
k++;
return 0;
marten 249% lint -u -m -x -Ncheck=%all test93.c
argument unused in function
(9) argc in main
(9) argv in main
set but not used in function
(10) val in main
.c file has no corresponding .h file
/nfs/m_usr/dhollen/junk/test93.c
assigned value never used
val defined at test93.c(10) :: set at test93.c(14)

The value of variable "val" is never actually used in function main.
You could delete its declaration and the assignment to it in the while-loop header without affecting the program.
Maybe you are thinking that the line
while ((val = get_value()) != 47)
uses the value of val. An assignment-expression has the type and value that is stored in the left operand, and is not an lvalue. The actual storage into the variable is a side effect that need not occur before the value of the assignment is used.
Reference: C99 Standard, section 6.5.16 "Assignment operators", paragraph 3.
In this example, the storage into val must occur before entering or skipping the loop body, but need not occur before evaluating the control expression. Variable val is therefore not used in the function.
We can go further and notice that since storing into val is not an "observable side effect", a compiler is free to omit allocating the variable or storing into it.

Similar Messages

  • Missing warning: variable never used / variable assigned but never used

    As a former C(++) programmer I am used to that the compiler can give me warnings if a variable is declared but never referenced or only assigned.
    Is there a free tool that can do this ?? A similar function that can do the same with methods would also be extremely cool.
    Thanks in advance

    Here is a opensource tool that will do the checks that
    you require(plus a number more):
    http://pmd.sourceforge.net/
    Nice.
    I just gave the Eclipse plugin a go. It needs a little work to integrate more neatly and usefully into the IDE, but I like what I've seen of the framework so far.
    I'd give the dukes to w4rren

  • Local variable is never used

    I have some code like this:
      String s = null;
      if (<some test>)
        s = "whatever";
    }Eclipse tells warns that the local variable s is never used, which is somewhat understandable since the assignment of s is nested. Still, it's annoying. I don't want to turn off the warnings because I like to be notified of them in order to keep the code clean. Is there a reasonable way around this?

    It has nothing to do with it being "nested". Even without the if, the variable is not used. It's only assigned to. But you never use it. You never pass it to a method, or assign it to any other variable.
    You can
    * Get rid of the variable, since you're not using it for anything.
    * Use it.
    * Ignore the warning.
    * Turn off that warning in eclipse's settings. (Not recommended, IMHO.)

  • So many problems, Super Slow, inundated with apps I never use, yet they still run, No Contract, Can I do something about this? Or am I destined to be contracted for the rest of my life?

    I just want to own my phone.  I don't like the speed of it after 2 years, if it didn't have so much crap that I never use on it then at least I would know that it is degradation of the hardware and would renew contract and upgrade, but how can I justify that when it is more than likely the system software that is bogging the phone down.  Seriously I have lost all of my photos and videos, numerous times.  Had my 32g sd card wiped (required me to format it after the camera app saved a picture that was corrupt.  Aside from breaking my already broken (removed) phone, what are the downsides?  If I am going to end up renewing either way, why would you not try to salvage the already paid for device?  If verizon is unable to work with me on this should I take my business (customer since 2005, but lost my data plan so not real inclined to stay other than I've had zero problems in that time frame)  I am confused.  I don't want the hassle of having to change carriers, but my fear is that I will not be given an adequate option?  Any light that could be shone down upon this matter would be greatly appreciated.  and sorry, I know this is probably a hot topic (maybe not) but I just want some legit answers and HTC puts the blame square on Verizon.  Thanks
    Edited as required by the Verizon Wireless Terms of Service
    Message was edited by: Admin Moderator

        beenycrocker,
    I can understand having a phone that is in good working condition. I am sorry to hear about the SD card getting formatted. I use my phone as my digital camera now days. Have you tried to perform a factory reset on the device to see if that will help with the speed of the phone?
    Good news! You can always upgrade to a new phone without having to sign a 2 year contact. We do have the great program that is called EDGE. With this program you would get a brand new device at full retail cost of the phone. But those payments are split up into 24 months. Once you have paid off more than 50% of the phone and had the EDGE for longer than 30 days you can trade in that phone and get a brand new device. You can see the full details on that plan here: www.verizonwireless.com/edge Please keep us posted.
    Kevin_R
    Follow us on Twitter @VZWSupport

  • Java 7u45 gives spurious warning about missing Permissions attribute

    The security dialog in 7u45 gives a yellow warning about missing Permissions attribute.   Does anyone know how to get rid of it?
    Same as the yellow box in the screenshots (#2 and #3) documented here (although none of them discuss the Permissions attribute) :
    What should I do when I see a security prompt from Java?
    The MANIFEST.MF file for the app definitely contains this attribute.  There's only one jar for the application, and it's signed.
    Might this be another security dialog bug?  Or am I missing something?  The JNLP contains the same "all-permissions" security tag.
    I also found the release notes for 7u45 mention a couple of cases where the dialog might still appear
    (see last issue: Java™ SE Development Kit 7 Update 45 Release Notes)
    I don't use the JNLPDownloadServlet but my own. I didn't model it on the JNLPDownloadServlet, but guess I could have partly the same issue since I use versioning.
    My jar doesn't fail to download though, it's just that its displaying this warning.
    MANIFEST.MF:
    Manifest-Version: 1.0
    Implementation-Title: My app
    Implementation-Version: 3.0-SNAPSHOT
    Built-By: me
    Application-Name: Myapp
    Created-By: Apache Maven 3.0.5
    Ant-Version: Apache Ant 1.8.2
    Trusted-Library: true
    Implementation-Vendor-Id: org.me
    Trusted-Only: true
    Build-Jdk: 1.7.0_45
    Permissions: all-permissions
    Specification-Title: my-client
    Specification-Version: 3.0-SNAPSHOT
    Archiver-Version: Plexus Archiver
    Codebase: *.me.org

    I went the Java version detection applet and I don't get a warning about the applet being blocked in the future.
    https://java.com/en/download/installed.jsp
    https://java.com/en/download/installed.jsp
    I dug the jar for the applet out of my Java cache and it contains Manifest.MF with the following contents:
    Manifest-Version: 1.0
    Codebase: www.java.com java.com
    Created-By: 1.7.0_25 (Oracle Corporation)
    Permissions: all-permissions
    Application-Library-Allowable-Codebase: www.java.com java.com
    Application-Name: Java Detection
    Name: JNLP-INF/APPLICATION.JNLP
    SHA1-Digest: jPquHTBq5R8txQLe5/T20x70Y7w=
    Name: JavaDetection.class
    SHA1-Digest: kQNVjPC5Yym1DszdpX1D2EH8Ll0=
    The jar contains one Java class and a signed JNLP-INF/APPLICATION.JNLP file that looks like this:
    <?xml version="1.0" encoding="UTF-8"?>
    <jnlp codebase="https://java.com/en/download/" href="JavaDetection_applet.jnlp" spec="1.0+">
        <information>
            <title>Java Detection</title>
            <vendor>Oracle Inc.</vendor>
        </information>
        <resources>
            <!-- Application Resources -->
      <j2se version="1.6+"/>
            <jar href="JavaDetection.jar" />
        </resources>
    <security>
      <all-permissions />
    </security>
        <applet-desc
             name="Java Detection Applet"
             main-class="JavaDetection"
             width="1"
             height="1">
         </applet-desc>
         <update check="background"/>
    </jnlp>
    They are running applet via JNLP:
    <applet code="JavaDetection.class" width="500" height="150"><param name="image" value="/im/download/verify_anim.gif"/><param name="centerimage" value="true"/><param name="boxborder" value="false"/><param name="jnlp_href" value="JavaDetection_applet.jnlp"/></applet>
    The JNLP file downloaded from here: https://java.com/en/download/JavaDetection_applet.jnlp matches the signed JNLP file in the jar (except for name).
    We are still working on getting our applications to not show the warning message but this appears to be an example of where the "you will be blocked in the future" message is not happening. We don't run our applications as applets so if anyone can find another working example that is a more traditional JNLP app, please post a link.

  • How to use warn about changes property with page menus

    how to use warn about changes property with page menus

    Hi,
    If u will enable this property, then u will get warning message as a popup in case of change of state of VO.
    Regards,,
    Gyan

  • Been using iTunes for about 2 years on the same MacBook Pro, just opened it and found everthing's gone. It's as if I'd never used it before. Any ideas, please?

    Been using iTunes for about 2 years on the same MacBook Pro, just opened it and found everthing's gone. It's as if I'd never used it before. Any ideas, please?

    Simply restore from your backup.
    You do have Time Machine running, yes?
    Or you use some other backup program?

  • Can't open iphoto in airbook. Asking to upgrade then says must rebuild library then warning about missing files. When click rebuild all I get is continued- waiting for iphoto library- and, never rebuilds

    can't open iphoto in airbook. Asking to upgrade then says must rebuild library then warning about missing files. When click rebuild all I get is continued- waiting for iphoto library- and, never rebuilds

    -1.The photo library needs to be upgraded to work with this version of iPhoto.
    Your photo library will not be readable by previous versions of iPhoto after the upgrade. The upgrade process for very large libraries may take an hour or more to complete.
    2. iPhoto is unable to open this library.
    The library has issues that require rebuilding to correct
    3. Warning
    Would you like to rebuild the library "iPhoto Library"? 
    The library "iPhoto Library" is missing required database files and must be rebuilt before it can be opened.
    4. Waiting for iPhoto library
    iPhoto will open as soon as the iPhoto library is available
    Time Machine might be backing it up

  • 3?'s: Message today warning lack of memory when using Word (files in Documents) something about "idisc not working" 2. Message week ago "Files not being backed up to Time Capsule"; 3. When using Mac Mail I'm prompted for password but none work TKS - J

    3 ?'s:
    1  Message today warning lack of memory when using Word (files in Documents) something about "idisc not working"
    2. Message week ago "Files not being backed up to Time Capsule";                                                                                                                                             
    3. When using Mac Mail I'm prompted for password but none work
    Thanks - J

    Thanks Allan for your quick response to my amateur questions.
    Allan:     I'm running version Mac OS X Version 10.6.8     PS Processor is 2.4 GHz Intel core 15 
    Memory  4 gb  1067   MHz  DDr3  TN And @ 1983-2011 Apple Inc.
    I just "Updated Software" as prompted.
    Thanks for helping me!    - John Garrett
    PS.
    Hardware Overview:
      Model Name:          MacBook Pro
      Model Identifier:          MacBookPro6,2
      Processor Name:          Intel Core i5
      Processor Speed:          2.4 GHz
      Number Of Processors:          1
      Total Number Of Cores:          2
      L2 Cache (per core):          256 KB
      L3 Cache:          3 MB
      Memory:          4 GB
      Processor Interconnect Speed:          4.8 GT/s
      Boot ROM Version:          MBP61.0057.B0C
      SMC Version (system):          1.58f17
      Serial Number (system):          W8*****AGU
      Hardware UUID:          *****
      Sudden Motion Sensor:
      State:          Enabled
    <Edited By Host>

  • I buy my numbers april 2013 , never used, then now toldme that,  I cant use in my mac ios, what happen about?

    I buy my numbers april 2013 , never used, then now toldme that,  I cant use in my mac ios, what happen about?

    Hi,
    Do you mean Numbers for the Mac or Numbers for iOS?
    If you bought Numbers for the Mac in April 2013 then you can still use it, and also download the new version for free.
    If you bought Numbers for iOS in April 2013 then you can update it to the latest Numbers for iOS.
    But Numbers for the Mac and Numbers for iOS are two different apps that need to be purchased separately. 
    They do come free with new iOS devices and Macs.
    SG

  • HT1477 i bought about 18 months ago and never used it, now it won't charge

    i bought about 18 months ago and never used it, now it won't charge

    A cracked screen is not covered by warranty.

  • How do I get rid of the specific warning about not having backed up to i Cloud for 2 weeks. I cannot use my iPad at present.

    How do I get rid of the specific warning about not having backed up to i Cloud for 2 weeks. I cannot use my iPad at present.

       

  • I get a warning about using an old version even after installing v24.

    Several websites (including Mozilla) give me a warning about using an old version. I'm currently on v24 and when I take the advice to upgrade it simply re-installs v24 again but the out of date message doesn't go away!

    Philipp,
    Sorry, should have read the ENTIRE message you sent. Problem solved - thank you so much. Have a great day.

  • HT4623 I cannot install my ipod to my computer. Says something about the device driver. I did not get it new either and so have no info about it. And I have never used one before and have no friends who have either. Can someone help me?

    I cannot install my ipod to my computer. Says something about the device driver. I did not get it new either and so have no info about it. And I have never used one before and have no friends who have either. Can someone help me?

    See
    iOS: Device not recognized in iTunes for Windows
    - I would start with
    Removing and Reinstalling iTunes, QuickTime, and other software components for Windows XP
    or              
    Removing and reinstalling iTunes and other software components for Windows Vista, Windows 7, or Windows 8
    However, after your remove the Apple software components also remove the iCloud Control Panel via Windows Programs and Features app in the Window Control Panel. Then reinstall all the Apple software components
    - New cable and different USB port
    - Run this and see if the results help with determine the cause
    iTunes for Windows: Device Sync Tests
    Also see:
    iPod not recognised by windows iTunes
    Troubleshooting issues with iTunes for Windows updates
    - Try on another computer to help determine if computer or iPod problem

  • ICC profiles - never used what have I been missing?

    Up until now I have never used separate icc profiles but have had to download all new drivers from epson to run my scanner and printer on new Intel Mac OSX 10.6. therefore it has given me the option to download the profiles.
    Any advise for using them, can you turn them off - will i never want to turn them off?
    What do they do exactly?
    I may sound daft to many but unless I ask I dont learn, many thanks in advance.

    Good advice so far and it is good that you ask these questions.
    You asked earlier about your Epson printouts matching a print shop. It helps to understand color management as a communication chain. In the case of images, this is an ideal workflow:
    1. Digital image is captured in RAW
    2. Photographer converts RAW data into an RGB image. The result is referred to as a source image. It should have an embedded RGB profile, for example Adobe RGB 1998. To see if it has an embedded profile, look at the document title in the window.  If you don't see # at the end, the image has a profile, which is good. If you do see #, you have a broken image, and it's up to you to get the derailed train back on track. If the image looks good to you (on a properly calibrated and profiled monitor) tagging an untagged image is an easy task. Edit: Assign Profile, and select your working RGB.
    3. The source image gets converted to the printer's CMYK color space, also represented by an ICC profile. This should be supplied by the printer. You do have the option of leaving the image RGB and letting Quark do the conversion when you output. Quark color management is somewhat more complicated to setup than InDesign CM, let me know if you have questions.
    4. To soft proof how the image will look on press, first calibrate and profile your monitor with the proper hardware and software. Then open the RGB image in Photoshop. View: Proof Setup: Custom, and select the CMYK profile supplied by the printer. The colors may shift some but that is to be expected, a CMYK color space is usually much smaller than most RGB color spaces.
    5. To proof an image on your Epson that will closely match the press, you can calibrate and profile your Epson (best) or use the canned factory profile corresponding to the paper loaded in the Epson. This profile is actually an RGB profile (the printer is not RGB but the profile that describes it is). Open the RGB image. In the print dialog under Color Management, choose "Proof." Color Handling, "Photoshop Manages Colors." Printer profile, select the Epson profile. Proof Setup, select the CMYK profile supplied by printer. Check "Simulate Paper Color"
    When you print, print Photoshop will perform two conversions behind the scenes. First your RGB image goes to the CMYK color space. Then the CMYK image is converted to the Epson profile using an Absolute Colorimetric rendering intent.
    Unfortunately I don't believe Quark has the ability to perform two conversions on output. So if you need to proof a Quark page it's a matter of conversion to the printer's CMYK when you export the PDF. Then you can print the CMYK PDF to your Epson from Acrobat, using Acrobat Color Management and selecting the appropriate Epson profile.

Maybe you are looking for