[OpenJDK 2D-Dev] <AWT Dev> awt_Robot.c : format string contains '\0' within the string body

Sergey Bylokhov sergey.bylokhov at oracle.com
Fri Jul 19 21:05:52 UTC 2019


Hi, Matthias. 


I think it is unneeded and can be removed. 


----- matthias.baesken at sap.com wrote: 
> 
> 
> 

Hello, is there a special reason to put a '\0' at the end of the “atom_name” - parameter of the XInternAtom call in isXCompositeDisplay ? 



jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c : 



static jboolean isXCompositeDisplay(Display *display, int screenNumber) { 



char NET_WM_CM_Sn[25]; 

snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber); 



Atom managerSelection = XInternAtom(display, NET_WM_CM_Sn, 0); 





I think on UNIX the snprintf implementations are conforming and zero-terminate ( exception was VS before VS2015 but this is unix/native code ). 



Reason why I ask is this warning we have in our AIX xlc16/xlclang build : 





/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_Robot.c:153:65: warning: format string contains '\0' within the string body [-Wformat] 

snprintf(NET_WM_CM_Sn, sizeof(NET_WM_CM_Sn), "_NET_WM_CM_S%d\0", screenNumber); 







Thanks, Matthias
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.openjdk.java.net/pipermail/2d-dev/attachments/20190719/eb53aaaa/attachment.html>


More information about the 2d-dev mailing list