473,763 Members | 1,908 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

junk value in variable

void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window
Nov 14 '05 #1
5 3002
risha wrote:
void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
what if fl_ad is NULL? check for ptr==Null before dereferencing.

you have updated the value of ulvald with the value @ fl_ad. Why should
it should show 0?
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window


Why should it be junk value? You are passing a pointer to FlashReadM,
so my assumption is that you want to read the value at location pointed
to by fl_ad, which must not be junk or else why read it?

Its junk to you beacuase you expect 0, but it would probably certianly
make sense for the FlashReadM! Ask Him.

HTH
--
Taran

Nov 14 '05 #2
risha wrote:
void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb)
{
unsigned long ulvald;
abb=2;
ulvald=0;
//fl_ad=(volatile unsigned long *)0x8020;
ulvald= *(fl_ad);
what if fl_ad is NULL? check for ptr==Null before dereferencing.

you have updated the value of ulvald with the value @ fl_ad. Why should
it should show 0?
//return ucVal;
}

in the above prg the value of abb is shown as 2 but the value of
ulvald does not show 0 it shows a junk value in the debugger memeory
window


Why should it be junk value? You are passing a pointer to FlashReadM,
so my assumption is that you want to read the value at location pointed
to by fl_ad, which must not be junk or else why read it?

Its junk to you beacuase you expect 0, but it would probably certianly
make sense for the FlashReadM! Ask Him.

HTH
--
Taran

Nov 14 '05 #3
Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb)
{
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
*************** *************** *************** *************** *******
1>My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as 0
at this point.
(memory in the debugger window indicates junk value)

2>When it reaches line #6 it should now load the value which is at
address location fl_ad which has the value passed as a parameter in
the function.The value at that location here in my case 0x8020 has
value 0x03.After the execution of line #6 in the debugger window for
memory it should indicate the new value atleast but here it neither
shows 0 in the beginnning nor 3 as the value.So it is junk value
again!!!
3>"what if fl_ad is NULL? check for ptr==Null before dereferencing."
The debugger indicates the correct address 0x8020.Hence not null.

4>so my assumption is that you want to read the value at location
pointed
to by fl_ad,

Absolutely right sir thats what I am trying to do.

Probably since it did not even initiaze i think something is really
wrong here....

I am a student and any help will do me good,(sorry for the long
message)
Thanks in advance,
Nov 14 '05 #4
risha wrote:

Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb) {
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
*************** *************** *************** *************** *******
1> My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as
0 at this point. (memory in the debugger window indicates junk value)


What sort of optimization is the compiler doing? There is no
reason for it to generate any code for line 4, because that value
is never used, and is immediately overwritten by line 6.

BTW, please DO NOT use nuisance abbreviations such as 'u' or
'prm'. They only serve to make your article hard to read and to
annoy.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #5
risha wrote:

Thank u for the reply sir. But the mistake lies on my part in not
making things clear. For conveinence I have numbered the prm
statements.

1.void FlashReadM(vola tile unsigned long *fl_ad,unsigned long abb) {
2. unsigned long ulvald;
3. abb=2;
4. ulvald=0;
5. //fl_ad=(volatile unsigned long *)0x8020;
6. ulvald = *(fl_ad);
7. return ulvald;
}
*************** *************** *************** *************** *******
1> My question is in line #4 the varaible ulvald is assigned 0 after
line #4 is executed it should have initialzed the variable ulvald as
0 at this point. (memory in the debugger window indicates junk value)


What sort of optimization is the compiler doing? There is no
reason for it to generate any code for line 4, because that value
is never used, and is immediately overwritten by line 6.

BTW, please DO NOT use nuisance abbreviations such as 'u' or
'prm'. They only serve to make your article hard to read and to
annoy.

--
"If you want to post a followup via groups.google.c om, don't use
the broken "Reply" link at the bottom of the article. Click on
"show options" at the top of the article, then click on the
"Reply" at the bottom of the article headers." - Keith Thompson
Nov 14 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
46575
by: John Ramsden | last post by:
.... when the id 'junk' doesn't exist anywhere in the document, instead of returning 'object'?! I am using Javascript for a drop-down menu, slightly adapted from one by Angus Turnbull (see http://javascript.internet.com and http://gusnz.cjb.net, not that this is probably relevant but it deserves a plug ;-), on Internet Explorer v6.0.2800.1106. I need this feature of getElementById(), or an equivalent one (using sound and standard...
1
3237
by: Denzil | last post by:
Hi, I am retrieving my DB values and setting them in the MyRS::DoFieldExchange(CFieldExchange* pFX) function. One of these records is a Long datatype and could be "Null" in the DB table. The issue is when the DB value is retrieved it is fine for all integers but for a "Null" value it returns a junk long value and not a pre-defined value, say.
2
2138
by: not aaron | last post by:
I start out with a string. Which I then encode with my own algorithm changing every characters ascii value depending on a key. I then save it to a binary file. When I generate the initial string, it shows up fine. When I encode the string it shows up right. When I save the file it appends about 3 lines of random ascii characters (about the length of my original string). When I go back to decode the string, it works right for what...
16
2815
by: Jeff | last post by:
Im trying to memcpy a buffer from a filled in simple structure. When I memcpy and then print the resulting buffer, I see 7 locations that have junk before my data starts. My data structure is: struct command_pkt { char command_num; char command; }; typedef command_pkt COMMAND;
14
3543
by: HB | last post by:
As many of us know, when we send legitimate emails to real customers from our apps, those emails often end up in the Hotmail (and MSN -- and AOL, too) junk folder. I've done a lot of testing with Hotmail, using different domain sender names, different sending IPs, different SMTP servers, etc., different email text, and I still can't find out why Hotmail blocks so many good emails and throws them in the junk folder. The sending IP even has...
1
1545
by: Vinod | last post by:
Hi, In VC8 project, I am having a struct which is having a char* variable. Now I am creating a 3 elements array object for the struct. I send the base address of the object using VARIANT to a function where I am casting to struct again using reinterpret_cast. Then If I am trying to traverse the array object from the index 0 to 2, it is working fine, If I am going for the index 3rd element, that char* variable
1
3029
davydany
by: davydany | last post by:
Hey guys...a n00b Here for this site. I'm making a sequence class for my C++ class. And The thing is in the array that I have, lets say i put in {13,17,38,18}, when i see the current values for the array data from 0 to3, I get this {13, JUNK VALUE, 17,38, 18} and JUNK VALUE is like 1.8e831 or something like that. This happens when I use the attach() function and use the current() function to display the values at data I really want to...
4
6111
by: situ | last post by:
Hello all, i have a column in a table which stores tag lines which are usually less than 500 charecter. when we display the data through the browser some character display as "boxes" or junks. i predict it may be the newline or carriage return character. is there any function so that i can ward of these characters my database is under utf 8 and my db2level is
1
2344
by: Pradeep | last post by:
Hi All, I am facing an issue where length method of std::string class gives a junk value when used in a expression. Here's an example. The code should not go into the for loop but it does because the value of j-str.length comes out to be some junk value int j = 12; std::string
0
9566
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
9389
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
10003
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9943
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,...
0
9828
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7370
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
5271
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...
0
5410
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2797
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.