Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upUse cstr macro for ffi literal strings #19925
Conversation
highfive
commented
Feb 1, 2018
|
This currently doesn't pass tidy test because it introduces new version of |
|
There was already a |
|
I think it's nice to use |
|
@emilio Do you mean a macro that returns a |
|
I meant the macro, but I don't really care. If you think using another crate is a good call, I'm fine with it :) |
|
Updated the |
|
@bors-servo r+ |
|
|
Use cstr macro for ffi literal strings Use `cstr!()` macro with `CStr` to ensure that literal strings used with FFI is properly nul-terminated to avoid cases like #19915. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19925) <!-- Reviewable:end -->
|
|
|
In
In Compiling geckoservo v0.0.1 (file:///home/servo/buildbot/slave/linux-dev/build/ports/geckolib)
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:397:29
|
397 | Action::Drop => cstr!("PEDeclDropped").as_ptr(),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:396:29
|
396 | Action::Skip => cstr!("PEDeclSkipped").as_ptr(),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:375:27
|
375 | ) => (cstr!("PEColorNotColor"), Action::Nothing),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:368:18
|
368 | (cstr!("PEUnknownAtRule"), Action::Skip),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:358:18
|
358 | (cstr!("PEDeclDropped"), Action::Nothing),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:352:25
|
352 | cstr!("PEDeclDropped")
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:349:25
|
349 | cstr!("PEMQNoMinMaxWithoutValue")
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:346:25
|
346 | cstr!("PEMQExpectedFeatureValue")
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:343:25
|
343 | cstr!("PEMQExpectedFeatureName")
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:340:25
|
340 | cstr!("PEGatherMediaNotIdent")
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:335:33
|
335 | return (prefix, cstr!("PEBadSelectorRSIgnored"), Action::Nothing);
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:329:34
|
329 | Some(cstr!("PENegationBadArg"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:326:34
|
326 | Some(cstr!("PEClassSelNotIdent"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:323:34
|
323 | Some(cstr!("PEPseudoSelBadName"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:320:34
|
320 | Some(cstr!("PEPseudoClassArgNotIdent"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:317:34
|
317 | Some(cstr!("PEPseudoSelEndOrUserActionPC"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:314:34
|
314 | Some(cstr!("PEPseudoSelUnknown"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:311:34
|
311 | Some(cstr!("PESelectorGroupExtraCombinator"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:308:34
|
308 | Some(cstr!("PESelectorGroupNoSelector"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:305:33
|
305 | Some(cstr!("PEUnknownNamespacePrefix"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:302:34
|
302 | Some(cstr!("PETypeSelNotType"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:299:34
|
299 | Some(cstr!("PEAttributeNameExpected"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:296:34
|
296 | Some(cstr!("PEAttributeNameOrNamespaceExpected"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:293:34
|
293 | Some(cstr!("PEAttSelBadValue"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:290:34
|
290 | Some(cstr!("PEAttSelNoBar"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:287:34
|
287 | Some(cstr!("PEAttSelUnexpected"))
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:281:18
|
281 | (cstr!("PEUnknownAtRule"), Action::Nothing)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:271:18
|
271 | (cstr!("PEAtNSUnexpected"), Action::Nothing)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:265:18
|
265 | (cstr!("PEBadSelectorKeyframeRuleIgnored"), Action::Nothing),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:263:18
|
263 | (cstr!("PEKeyframeBadName"), Action::Nothing),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:261:18
|
261 | (cstr!("PEUnknownFontDesc"), Action::Skip),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:259:18
|
259 | (cstr!("PEUnknownProperty"), Action::Drop),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:255:27
|
255 | _ => (cstr!("PEUnknownProperty"), Action::Drop)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:253:26
|
253 | (cstr!("PEValueParsingError"), Action::Drop)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:250:33
|
250 | cstr!("PEValueParsingError"), Action::Drop)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:249:38
|
249 | return (Some(cstr!("PEExpectedNoneOrURLOrFilterFunction")),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:246:33
|
246 | cstr!("PEValueParsingError"), Action::Drop)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:245:38
|
245 | return (Some(cstr!("PEColorNotColor")),
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:238:18
|
238 | (cstr!("PEParseDeclarationDeclExpected"), Action::Skip)
| ^^^^
error: cannot find macro `cstr!` in this scope
--> ports/geckolib/tests/../../../ports/geckolib/error_reporter.rs:382:26
|
382 | (cstr!("PEDeclDropped"), Action::Nothing)
| ^^^^
error: aborting due to 40 previous errors
error: Could not compile `stylo_tests`. |
|
Fixed the |
|
|
|
Looks like #20022 bumpped the versions of the dependencies I need here \o/ |
|
@bors-servo r=emilio |
|
|
Use cstr macro for ffi literal strings Use `cstr!()` macro with `CStr` to ensure that literal strings used with FFI is properly nul-terminated to avoid cases like #19915. <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/19925) <!-- Reviewable:end -->
|
|
upsuper commentedFeb 1, 2018
•
edited by SimonSapin
Use
cstr!()macro withCStrto ensure that literal strings used with FFI is properly nul-terminated to avoid cases like #19915.This change is