This repository was archived by the owner on Nov 9, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 63
Fix oacr build warnings #68
Open
kasontey
wants to merge
6
commits into
master
Choose a base branch
from
fixoacrbuildwarnings
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
78c79e8
resolving oacr build warnings
db652ee
taking away unintentional changes
8a6c337
CR feedback
7d6bc77
moving back to sizeof and adding TRUNCATE
b31e730
fixing linux build error
c028bd2
adding stdlib for _TRUNCATE use
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -842,7 +842,7 @@ static int _media_send_slot(ftl_stream_configuration_private_t *ftl, nack_slot_t | |
| int pkt_len; | ||
|
|
||
| os_lock_mutex(&ftl->media.mutex); | ||
| memcpy(pkt, slot->packet, slot->len); | ||
| memcpy_s(pkt, sizeof(pkt), slot->packet, slot->len); | ||
|
||
| pkt_len = slot->len; | ||
| os_unlock_mutex(&ftl->media.mutex); | ||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe you want something like strlen here, sizeof will return the size of the type which I think is char*, so 4 bytes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you call strlen on a char[] ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Of course, [] and * is the same in C anyway. (Both are a pointer, it is just syntactic sugar, really).
Also sizeof(char*) is 8 bytes on 64-bit :p
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hmmm, but there should be a nice way to get the count
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, strlen will look through the array until it finds a '/0'
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was confused about your page numbers there for a while.
Apparently, pdf page 92 is standard page 80 :)
Anyway, I actually have no idea what type the "string" field has. I assumed that, being a field it was not char[], but char[x] (which behave differently in sizeof, at least in C++)
So, what is it? char[] or char[x]?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah, sorry about the page confusion.
The "string" variable is a char[1024] in a struct which is in the msg union, which is in the m struct.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://ideone.com/1YQUTV there we go
So this means that "m.msg.log.string" cannot actually be a char[], assuming this piece of code compiles in gcc 6.3 :)
This means it's likely char[x] and sizeof was correct.
If, however, it is char*, you cannot use sizeof. In that case, you need the size from somewhere else. If it's not initialized and you did not store the length somewhere alongside the pointer, good luck figuring out the length :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup so seems like this is a char[x], so I'll move this back to sizeof.
And for the count we'll use the _TRUNCATE for string truncation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call. Thanks everyone!