Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Eliminate duplicated code when dealing with pointer data #36822

Merged
merged 11 commits into from Nov 10, 2022

Conversation

fzyzcjy
Copy link
Contributor

@fzyzcjy fzyzcjy commented Oct 17, 2022

Hope the PR is self-explanatory :) If needed I can explain it.

List which issues are fixed by this PR. You must list at least one issue.

If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.

Pre-launch Checklist

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the Flutter Style Guide and the C++, Objective-C, Java style guides.
  • I listed at least one issue that this PR fixes in the description above.
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt. See testing the engine for instructions on
    writing and running engine tests.
  • I updated/added relevant documentation (doc comments with ///).
  • I signed the CLA.
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

memcpy(&data_[i * sizeof(PointerData)], &data, sizeof(PointerData));
}

PointerData PointerDataPacket::GetPointerData(size_t i) const {
FML_DCHECK(i < GetLength());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

DCHECK only runs in debug mode. if the goal of this PR is to add bounds checking to make it safe, you need to always perform the bounds check

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added DCHECK because originally there is no check at all and I dare not change semantics of the code (e.g. if no check because previous dev deliberately do so to avoid being too slow?). If you like, I will change to CHECK

Copy link
Contributor

@dnfield dnfield left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This LGTM as long as the goal is just to reduce some code duplication. I'm going to update the title to remove the safety parts since it's not actually any safer than the old code.

@dnfield dnfield changed the title Eliminate unsafe memcpy and duplicated code when dealing with pointer data Eliminate duplicated code when dealing with pointer data Oct 27, 2022
@dnfield dnfield added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2022
@auto-submit auto-submit bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 27, 2022
@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 27, 2022

auto label is removed for flutter/engine, pr: 36822, due to - Please get at least one approved review if you are already a member or two member reviews if you are not a member before re-applying this label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@auto-submit
Copy link
Contributor

auto-submit bot commented Oct 27, 2022

auto label is removed for flutter/engine, pr: 36822, due to Validations Fail.

@fzyzcjy
Copy link
Contributor Author

fzyzcjy commented Oct 27, 2022

@dnfield Sure.

Btw if you guys think the cost paid by CHECK is ok, I will change DCHECK to CHECK (pretty easy to change)

@dnfield
Copy link
Contributor

dnfield commented Oct 27, 2022

CHECK will cause a crash at runtime. DCHECK is probably fine here to make tests fail.

@chinmaygarde chinmaygarde added the autosubmit Merge PR when tree becomes green via auto submit App label Nov 10, 2022
@auto-submit auto-submit bot merged commit 2f5b7ac into flutter:main Nov 10, 2022
auto-submit bot pushed a commit to flutter/flutter that referenced this pull request Nov 10, 2022
…115118)

* 4f86f229d Update FlutterView.java (flutter/engine#37312)

* 80e31edb2 Adding release_build:true to Mac builds. (flutter/engine#37478)

* 2f5b7ac34 Eliminate duplicated code when dealing with pointer data (flutter/engine#36822)

* f831382b7 Install CIPD ninja using DEPS (flutter/engine#37375)

* 4cb9c1e00 mouse-input-view nit and add mouse-input-test to integration test script (flutter/engine#37441)
schwa423 pushed a commit to schwa423/engine that referenced this pull request Nov 16, 2022
* add methods

* add empty test

* add unit test

* Update licenses_flutter

* add const

* size -> get length

* add boundary checks

* add tests

* remove death test since it says "Death tests use fork(), which is unsafe particularly in a threaded context."
shogohida pushed a commit to shogohida/flutter that referenced this pull request Dec 7, 2022
…lutter#115118)

* 4f86f229d Update FlutterView.java (flutter/engine#37312)

* 80e31edb2 Adding release_build:true to Mac builds. (flutter/engine#37478)

* 2f5b7ac34 Eliminate duplicated code when dealing with pointer data (flutter/engine#36822)

* f831382b7 Install CIPD ninja using DEPS (flutter/engine#37375)

* 4cb9c1e00 mouse-input-view nit and add mouse-input-test to integration test script (flutter/engine#37441)
gspencergoog pushed a commit to gspencergoog/flutter that referenced this pull request Jan 19, 2023
…lutter#115118)

* 4f86f229d Update FlutterView.java (flutter/engine#37312)

* 80e31edb2 Adding release_build:true to Mac builds. (flutter/engine#37478)

* 2f5b7ac34 Eliminate duplicated code when dealing with pointer data (flutter/engine#36822)

* f831382b7 Install CIPD ninja using DEPS (flutter/engine#37375)

* 4cb9c1e00 mouse-input-view nit and add mouse-input-test to integration test script (flutter/engine#37441)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
autosubmit Merge PR when tree becomes green via auto submit App platform-fuchsia
Projects
None yet
4 participants