Coccinelle archive on
 help / color / Atom feed
* [Cocci] Type propagation of unknown field types in arithmetic operations
@ 2019-04-07 21:28 Michael Stefaniuc
  0 siblings, 0 replies; only message in thread
From: Michael Stefaniuc @ 2019-04-07 21:28 UTC (permalink / raw)
  To: Coccinelle

[-- Attachment #1: Type: text/plain, Size: 603 bytes --]


I've run into a new set of false positives in my quest to remove casts
to self:

If the type of a field is unknown then the cast to int will be kept

But if that field is involved in an arithmetic operation with a numeric
constant and the result gets casted to int then the cast gets
erroneously removed:
  (int)(s->unknown / 1000)

That happens only for fields as a the cast will be kept in for variables:
  (int)(unknown / 1000)

Also if the type of the field is known and doesn't matches then the cast
is correctly kept.

Test case is attached.


[-- Attachment #2: selfcast.cocci --]
[-- Type: text/plain, Size: 51 bytes --]

@ disable drop_cast @
type T;
T E;
- (T)

[-- Attachment #3: type.c --]
[-- Type: text/x-csrc, Size: 431 bytes --]

[-- Attachment #4: type.diff --]
[-- Type: text/x-patch, Size: 610 bytes --]

[-- Attachment #5: Type: text/plain, Size: 136 bytes --]

Cocci mailing list

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, back to index

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-07 21:28 [Cocci] Type propagation of unknown field types in arithmetic operations Michael Stefaniuc

Coccinelle archive on

Archives are clonable:
	git clone --mirror cocci/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 cocci cocci/ \
	public-inbox-index cocci

Newsgroup available over NNTP:

AGPL code for this site: git clone public-inbox